2020-12-04 17:10:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-19 15:01:11 +00:00
|
|
|
# Restore Nextcloud Filesystem
|
2020-12-04 17:10:24 +00:00
|
|
|
# TODO: describe input params
|
2020-11-27 08:16:25 +00:00
|
|
|
|
2020-11-19 15:01:11 +00:00
|
|
|
# Reads restore snapshot_ID from first CLI Argument
|
2020-12-11 16:55:18 +00:00
|
|
|
restic -r $RESTIC_REPOSITORY/files restore latest --target /var/backups/
|
2020-11-19 15:01:11 +00:00
|
|
|
|
|
|
|
# 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
|
2020-12-11 16:55:18 +00:00
|
|
|
restic -r $RESTIC_REPOSITORY/db restore latest --target test-stdin
|
2020-11-19 15:01:11 +00:00
|
|
|
# read folder and restore db entries
|
2020-12-11 16:55:18 +00:00
|
|
|
psql -d $(cat ${POSTGRES_DB_FILE}) -h $POSTGRES_SERVICE -p $POSTGRES_PORT -U $(cat ${POSTGRES_USER_FILE}) --no-password < test-stdin/stdin
|