Add (manual) recovery scripts

This commit is contained in:
Tobias Reisinger 2024-10-30 16:35:46 +01:00
parent a2c680f3e8
commit 4f97b66c3d
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 48 additions and 1 deletions

View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -e
tmp_dir=$(mktemp -d)
cd /opt/services/backup/
echo "Restoring backup..."
autorestic -c .autorestic.all.yml restore -l immich_database --from borgbase --to "$tmp_dir"
echo "Backup restored."
cd /opt/services/immich
echo "Starting database..."
docker compose up -d database
echo "Waiting for database to start..."
sleep 10
echo "Restoring database..."
cat "$tmp_dir/opt/services/_backup/immich_database/immich.sql.gz" \
| gunzip \
| sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" \
| docker exec -i immich-database-1 psql --username=immich
echo "Database restored."
echo "Removing temporary files..."
rm -rf "$tmp_dir"
echo "Starting services..."
docker compose up -d

View file

@ -31,6 +31,8 @@
- name: Import tasks specific to the hooks scripts
ansible.builtin.import_tasks: hooks.yml
- name: Import tasks specific to the recovery scripts
ansible.builtin.import_tasks: recovery.yml
- name: Import tasks specific to systemd
ansible.builtin.import_tasks: systemd.yml

View file

@ -0,0 +1,13 @@
- name: Set recovery path
ansible.builtin.set_fact:
recovery_path: "{{ (service_path, 'recovery') | path_join }}"
- name: Create recovery directory
ansible.builtin.file:
path: "{{ recovery_path }}"
state: directory
mode: "0755"
- name: Copy the recovery
ansible.builtin.copy:
src: recovery/
dest: "{{ recovery_path }}"
mode: "0755"

View file

@ -177,7 +177,7 @@ services = {
},
"immich" = {
host = "node002"
host = "node001"
dns = [{
domain = "gallery.serguzim.me"
}]