From b098a325f80c7988a16d92eae7ef9a7f71b5dd42 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Tue, 15 Nov 2022 09:19:55 -0800 Subject: [PATCH] Add backups for photoprism --- services/backups/backup.nomad | 7 +++++ services/backups/jobs/photoprism.hcl | 47 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 services/backups/jobs/photoprism.hcl diff --git a/services/backups/backup.nomad b/services/backups/backup.nomad index 697bed0..08b11d2 100644 --- a/services/backups/backup.nomad +++ b/services/backups/backup.nomad @@ -187,6 +187,13 @@ ${file("${module_path}/jobs/grafana.hcl")} {{ end -}} {{ end -}} +{{ range service "photoprism" -}} +# photoprism .Node {{ .Node }} +{{ if eq .Node (env "node.unique.name") -}} +${file("${module_path}/jobs/photoprism.hcl")} +{{ end -}} +{{ end -}} + {{ range service "lldap" -}} # lldap .Node {{ .Node }} {{ if eq .Node (env "node.unique.name") -}} diff --git a/services/backups/jobs/photoprism.hcl b/services/backups/jobs/photoprism.hcl new file mode 100644 index 0000000..6d25454 --- /dev/null +++ b/services/backups/jobs/photoprism.hcl @@ -0,0 +1,47 @@ +job "photoprism" { + schedule = "10 * * * *" + + config { + repo = "rclone::ftp,env_auth:/nomad/photoprism" + passphrase = env("BACKUP_PASSPHRASE") + } + + task "Create local photoprism dir" { + pre_script { + on_backup = "mkdir -p /local/photoprism" + } + } + + task "Backup database" { + mysql "Backup database" { + hostname = env("MYSQL_HOST") + port = env("MYSQL_PORT") + database = "photoprism" + username = env("MYSQL_USER") + password = env("MYSQL_PASSWORD") + no_tablespaces = true + dump_to = "/local/photoprism/dump.sql" + } + } + + # NOTE: Right now the cache and sidecar files are stored in the task local + # storage and not in a volume that can be backed up. This was done to allow + # Photoprism to be moved between hosts. If this directory becomes large and + # costly to move between hosts or regenerate, then it may be worth putting it + # on a host volume so it can be backed up as well. Possibly once I get NFS + # shares running from the Proxmox host available to the VMs for faster shared + # storage. + + backup { + paths = ["/local/photoprism"] + # Because path is absolute + restore_opts { + Target = "/" + } + } + + forget { + KeepLast = 2 + Prune = true + } +}