add backup and restore scripts
This commit is contained in:
parent
bcd04af38b
commit
556eb5abf3
2 changed files with 18 additions and 0 deletions
6
infrastrucure/docker/image/resources/backup.sh
Normal file
6
infrastrucure/docker/image/resources/backup.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
set -o pipefail
|
||||||
|
# backup database dump
|
||||||
|
pg_dump -d $(cat ${POSTGRES_DB_FILE}) -h $POSTGRES_SERVICE -p $POSTGRES_PORT -U $(cat ${POSTGRES_USER_FILE}) --no-password --serializable-deferrable --clean --no-privileges | \
|
||||||
|
restic -r $RESTIC_REPOSITORY --verbose backup --stdin --tag DB_Backup
|
||||||
|
# backup nextcloud filesystem
|
||||||
|
restic -r $RESTIC_REPOSITORY backup /var/backups/ --tag Nextcloud_Filesystem
|
12
infrastrucure/docker/image/resources/restore.sh
Normal file
12
infrastrucure/docker/image/resources/restore.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Restore Nextcloud Filesystem
|
||||||
|
# Reads restore snapshot_ID from first CLI Argument
|
||||||
|
restic -r $RESTIC_REPOSITORY restore $1 --target /
|
||||||
|
|
||||||
|
# Delete DB
|
||||||
|
psql -d template1 -h $POSTGRES_SERVICE -p $POSTGRES_PORT -U $(cat ${POSTGRES_USER_FILE}) --no-password -c "DROP DATABASE \"cloud\";"
|
||||||
|
# Create DB again
|
||||||
|
psql -d template1 -h $POSTGRES_SERVICE -p $POSTGRES_PORT -U $(cat ${POSTGRES_USER_FILE}) --no-password -c "CREATE DATABASE \"cloud\";"
|
||||||
|
# create folder from db backup
|
||||||
|
restic -r $RESTIC_REPOSITORY restore $2 --target test-stdin-$2
|
||||||
|
# read folder and restore db entries
|
||||||
|
psql -d $(cat ${POSTGRES_DB_FILE}) -h $POSTGRES_SERVICE -p $POSTGRES_PORT -U $(cat ${POSTGRES_USER_FILE}) --no-password < test-stdin-$2
|
Loading…
Reference in a new issue