28 lines
608 B
Bash
Executable file
28 lines
608 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
target="$1"
|
|
if [ -z "$target" ]; then
|
|
echo "No target given!"
|
|
exit 1
|
|
fi
|
|
recovery_file="pg_dump_$target.dump"
|
|
|
|
tmp_dir=$(mktemp -d)
|
|
recovery_file_path="$tmp_dir/opt/services/_backup/postgresql/$recovery_file"
|
|
|
|
cd /opt/services/backup/
|
|
|
|
echo "Restoring backup..."
|
|
autorestic -c .autorestic.all.yml restore -l postgresql --from borgbase --to "$tmp_dir"
|
|
echo "Backup restored."
|
|
|
|
echo "Recovery file: $recovery_file"
|
|
|
|
echo "Restoring database..."
|
|
sudo -u postgres pg_restore -C "$recovery_file_path"
|
|
echo "Database restored."
|
|
|
|
echo "Removing temporary files..."
|
|
rm -rf "$tmp_dir"
|