Add stage parameter for backup hooks and add immich_upload backup
This commit is contained in:
parent
4db5c1878b
commit
759368b6d6
8 changed files with 49 additions and 11 deletions
|
|
@ -2,5 +2,9 @@
|
|||
|
||||
backup_path="$1"
|
||||
|
||||
if [ "$2" != "before" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd /opt/services/immich || exit
|
||||
docker compose exec database sh -c 'pg_dump -U "$DB_USERNAME" "$DB_DATABASE"' | gzip >"$backup_path/immich.sql.gz"
|
||||
|
|
|
|||
12
playbooks/roles/backup/files/hooks/immich_upload
Executable file
12
playbooks/roles/backup/files/hooks/immich_upload
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
backup_path="$1"
|
||||
stage="$2"
|
||||
|
||||
if [ "$stage" == "before" ]; then
|
||||
rclone mount --config /opt/services/backup/rclone.conf --daemon immich_upload: "$backup_path"
|
||||
fi
|
||||
|
||||
if [ "$stage" == "after" ]; then
|
||||
unmount "$backup_path"
|
||||
fi
|
||||
|
|
@ -2,4 +2,8 @@
|
|||
|
||||
export MAILCOW_BACKUP_LOCATION="$1"
|
||||
|
||||
if [ "$2" != "before" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup all --delete-days 1
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
cd "$1"
|
||||
|
||||
if [ "$2" != "before" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
postgres_tables=$(sudo -u postgres psql -Atc "SELECT datname FROM pg_database WHERE datistemplate = false;")
|
||||
|
||||
for i in $postgres_tables
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@
|
|||
content: '{{ backup_yml_all | to_nice_yaml }}'
|
||||
mode: "0644"
|
||||
|
||||
- name: Create rclone.conf
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ (service_path, 'rclone.conf') | path_join }}"
|
||||
content: '{{ vault_backup.rclone }}'
|
||||
mode: "0600"
|
||||
|
||||
- name: Import tasks specific to the hooks scripts
|
||||
ansible.builtin.import_tasks: hooks.yml
|
||||
- name: Import tasks specific to the recovery scripts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue