From ab6906e989e6a0bb82f0822403e468214a800d8d Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Sun, 10 Dec 2023 20:39:33 -0800 Subject: [PATCH] Gitea backups --- backups/jobs/git.hcl | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 backups/jobs/git.hcl diff --git a/backups/jobs/git.hcl b/backups/jobs/git.hcl new file mode 100644 index 0000000..925d938 --- /dev/null +++ b/backups/jobs/git.hcl @@ -0,0 +1,57 @@ +job "git" { + schedule = "@daily" + + config { + repo = "s3://backups-minio.agnosticfront.thefij:8443/nomad/gitea" + passphrase = env("BACKUP_PASSPHRASE") + + options { + InsecureTls = true + } + } + + task "Create local gitea dir" { + pre_script { + on_backup = "mkdir -p /local/gitea" + } + } + + task "Backup database" { + mysql "Backup database" { + hostname = env("MYSQL_HOST") + port = env("MYSQL_PORT") + database = "gitea" + username = env("MYSQL_USER") + password = env("MYSQL_PASSWORD") + no_tablespaces = true + dump_to = "/local/gitea/dump.sql" + } + } + + backup { + paths = [ + "/local/gitea" + "/data/nas-container/gitea", + ] + + backup_opts { + Host = "nomad" + } + + restore_opts { + Host = ["nomad"] + # Because path is absolute + Target = "/" + } + } + + forget { + KeepLast = 2 + KeepHourly = 24 + KeepDaily = 30 + KeepWeekly = 8 + KeepMonthly = 6 + KeepYearly = 2 + Prune = true + } +}