From d8f8884cb826f272ec55fbcd7251527d4446a878 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 3 Aug 2023 09:55:00 -0700 Subject: [PATCH] Improve backup job configuration Add lidarr, fix hosts to 'nomad' since host names change with containers and nodes and don't make a difference, make most jobs daily, exclude sonarr and lidarr zip backups from restic backups. --- services/backups/jobs/grafana.hcl | 10 ++++- services/backups/jobs/lidarr.hcl | 56 ++++++++++++++++++++++++++++ services/backups/jobs/lldap.hcl | 8 +++- services/backups/jobs/nextcloud.hcl | 10 ++++- services/backups/jobs/nzbget.hcl | 8 +++- services/backups/jobs/photoprism.hcl | 8 +++- services/backups/jobs/sabnzbd.hcl | 8 +++- services/backups/jobs/sonarr.hcl | 28 +++++++++++++- 8 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 services/backups/jobs/lidarr.hcl diff --git a/services/backups/jobs/grafana.hcl b/services/backups/jobs/grafana.hcl index 2406cbc..2c69813 100644 --- a/services/backups/jobs/grafana.hcl +++ b/services/backups/jobs/grafana.hcl @@ -1,5 +1,5 @@ job "grafana" { - schedule = "0 * * * *" + schedule = "@daily" config { repo = "rclone::ftp,env_auth:/nomad/grafana" @@ -26,8 +26,14 @@ job "grafana" { backup { paths = ["/local/grafana"] - # Because path is absolute + + backup_opts { + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } } diff --git a/services/backups/jobs/lidarr.hcl b/services/backups/jobs/lidarr.hcl new file mode 100644 index 0000000..708a49e --- /dev/null +++ b/services/backups/jobs/lidarr.hcl @@ -0,0 +1,56 @@ +job "lidarr" { + schedule = "@daily" + + config { + repo = "rclone::ftp,env_auth:/nomad/lidarr" + passphrase = env("BACKUP_PASSPHRASE") + } + + task "Backup main database" { + postgres "Backup database" { + hostname = env("MYSQL_HOST") + port = env("MYSQL_PORT") + username = env("MYSQL_USER") + password = env("MYSQL_PASSWORD") + database = "lidarr" + no_tablespaces = true + dump_to = "/data/nas-container/lidarr/Backups/dump-lidarr.sql" + } + } + + task "Backup logs database" { + postgres "Backup database" { + hostname = env("MYSQL_HOST") + port = env("MYSQL_PORT") + username = env("MYSQL_USER") + password = env("MYSQL_PASSWORD") + database = "lidarr-logs" + no_tablespaces = true + dump_to = "/data/nas-container/lidarr/Backups/dump-lidarr-logs.sql" + } + } + + backup { + paths = ["/data/nas-container/lidarr"] + + backup_opts { + Exclude = ["lidarr_backup_*.zip"] + Host = "nomad" + } + + restore_opts { + Host = ["nomad"] + # Because path is absolute + Target = "/" + } + } + + forget { + KeepLast = 2 + KeepDaily = 30 + KeepWeekly = 8 + KeepMonthly = 6 + KeepYearly = 2 + Prune = true + } +} diff --git a/services/backups/jobs/lldap.hcl b/services/backups/jobs/lldap.hcl index 2085836..1cb6c84 100644 --- a/services/backups/jobs/lldap.hcl +++ b/services/backups/jobs/lldap.hcl @@ -26,8 +26,14 @@ job "lldap" { backup { paths = ["/local/lldap"] - # Because path is absolute + + backup_opts { + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } } diff --git a/services/backups/jobs/nextcloud.hcl b/services/backups/jobs/nextcloud.hcl index 5678616..2103a53 100644 --- a/services/backups/jobs/nextcloud.hcl +++ b/services/backups/jobs/nextcloud.hcl @@ -1,5 +1,5 @@ job "nextcloud" { - schedule = "0 * * * *" + schedule = "@daily" config { repo = "rclone::ftp,env_auth:/nomad/nextcloud" @@ -18,8 +18,14 @@ job "nextcloud" { backup { paths = ["/data/nextcloud"] - # Because path is absolute + + backup_opts { + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } } diff --git a/services/backups/jobs/nzbget.hcl b/services/backups/jobs/nzbget.hcl index 9c9e9e3..bb16e02 100644 --- a/services/backups/jobs/nzbget.hcl +++ b/services/backups/jobs/nzbget.hcl @@ -13,8 +13,14 @@ job "nzbget" { # Queued nzb files "/data/media-write/Downloads/nzb", ] - # Because path is absolute + + backup_opts { + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } } diff --git a/services/backups/jobs/photoprism.hcl b/services/backups/jobs/photoprism.hcl index 533a9fb..713dc65 100644 --- a/services/backups/jobs/photoprism.hcl +++ b/services/backups/jobs/photoprism.hcl @@ -29,8 +29,14 @@ job "photoprism" { "/local/photoprism", "/data/nas-container/photoprism", ] - # Because path is absolute + + backup_opts { + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } } diff --git a/services/backups/jobs/sabnzbd.hcl b/services/backups/jobs/sabnzbd.hcl index 42c3862..6533bd9 100644 --- a/services/backups/jobs/sabnzbd.hcl +++ b/services/backups/jobs/sabnzbd.hcl @@ -8,8 +8,14 @@ job "sabnzbd" { backup { paths = ["/data/media-write/Downloads/sabnzbd"] - # Because path is absolute + + backup_opts { + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } } diff --git a/services/backups/jobs/sonarr.hcl b/services/backups/jobs/sonarr.hcl index e3aecbc..67e99ba 100644 --- a/services/backups/jobs/sonarr.hcl +++ b/services/backups/jobs/sonarr.hcl @@ -6,11 +6,37 @@ job "sonarr" { passphrase = env("BACKUP_PASSPHRASE") } + task "Backup main database" { + sqlite "Backup database" { + path = "/data/sonarr/sonarr.db" + dump_to = "/data/sonarr/Backups/sonarr.db.bak" + } + } + + task "Backup logs database" { + sqlite "Backup database" { + path = "/data/sonarr/logs.db" + dump_to = "/data/sonarr/Backups/logs.db.bak" + } + } + backup { # Not dunping sqlite because sonarr makes dumps paths = ["/data/sonarr"] - # Because path is absolute + + backup_opts { + Exclude = [ + "sonarr_backup_*.zip", + "*.db", + "*.db-shm", + "*.db-wal", + ] + Host = "nomad" + } + restore_opts { + Host = ["nomad"] + # Because path is absolute Target = "/" } }