33 lines
801 B
Text
33 lines
801 B
Text
|
#!/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
|