2022-08-19 09:59:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-12-21 21:21:33 +00:00
|
|
|
set -Eexo pipefail
|
2022-08-19 09:59:04 +00:00
|
|
|
|
|
|
|
function main() {
|
2024-08-16 14:29:34 +00:00
|
|
|
local db_snapshot_id="${1:-latest}"
|
|
|
|
local file_snapshot_id="${2:-latest}"
|
2022-08-19 09:59:04 +00:00
|
|
|
|
|
|
|
file_env AWS_ACCESS_KEY_ID
|
|
|
|
file_env AWS_SECRET_ACCESS_KEY
|
|
|
|
|
|
|
|
file_env POSTGRES_DB
|
|
|
|
file_env POSTGRES_PASSWORD
|
|
|
|
file_env POSTGRES_USER
|
|
|
|
|
|
|
|
# Restore latest snapshot into /var/backups/restore
|
2024-08-16 14:29:34 +00:00
|
|
|
restore-directory '/var/backups/restore' ${file_snapshot_id}
|
2022-08-19 09:59:04 +00:00
|
|
|
|
2022-09-16 13:23:25 +00:00
|
|
|
rm -rf /var/backups/gitea/*
|
|
|
|
rm -rf /var/backups/git/repositories/*
|
2024-08-16 17:13:58 +00:00
|
|
|
mv /var/backups/restore/gitea /var/backups/
|
|
|
|
mv /var/backups/restore/git/repositories /var/backups/git/
|
2022-08-19 09:59:04 +00:00
|
|
|
|
2022-09-16 13:23:25 +00:00
|
|
|
# adjust file permissions for the git user
|
|
|
|
chown -R 1000:1000 /var/backups
|
2022-08-19 09:59:04 +00:00
|
|
|
|
2022-09-16 14:44:14 +00:00
|
|
|
# TODO: Regenerate Git Hooks? Do we need this?
|
2022-09-16 13:23:25 +00:00
|
|
|
#/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks
|
2022-08-19 09:59:04 +00:00
|
|
|
|
|
|
|
# Restore db
|
|
|
|
drop-create-db
|
2024-08-16 14:29:34 +00:00
|
|
|
restore-db ${db_snapshot_id}
|
2022-08-19 09:59:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source /usr/local/lib/functions.sh
|
|
|
|
source /usr/local/lib/pg-functions.sh
|
|
|
|
source /usr/local/lib/file-functions.sh
|
|
|
|
|
2024-08-16 14:29:34 +00:00
|
|
|
main "$@"
|