From c591813f234e8c802458c5a2602a5662fc01d7df Mon Sep 17 00:00:00 2001 From: vincent porte Date: Tue, 26 Sep 2023 15:43:54 +0200 Subject: [PATCH] update script to restore last backup, using rcloned dump --- .env.template | 9 ++++++++- scripts/import-latest-db-backup.sh | 14 +++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.env.template b/.env.template index 9f49fa64e..364a5ea86 100644 --- a/.env.template +++ b/.env.template @@ -29,7 +29,7 @@ INCLUSION_CONNECT_CLIENT_ID=local_inclusion_connect INCLUSION_CONNECT_CLIENT_SECRET=__key_to_be_set__ # Path to the itou-backup project repository. -PATH_TO_BACKUPS=~/path/to/itou-backups +PATH_TO_BACKUPS=~/path/to/backups # bucket for test purpose only CELLAR_ADDON_KEY_ID=__id_to_be_set__ @@ -39,3 +39,10 @@ CELLAR_ADDON_PROTOCOL=https S3_STORAGE_BUCKET_NAME=c3-storage-test-prive S3_STORAGE_BUCKET_NAME_PUBLIC=c3-storage-test-public S3_STORAGE_BUCKET_REGION=eu-west-3 + +# itou-backups +export RCLONE_S3_ACCESS_KEY_ID=ACCESS_KEY_ID +export RCLONE_S3_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY +export RCLONE_CRYPT_PASSWORD=CRYPT-PASSWORD +export RCLONE_CRYPT_PASSWORD2=CRYPT-PASSWORD2 +export RCLONE_REMOTE_NAME=communaute diff --git a/scripts/import-latest-db-backup.sh b/scripts/import-latest-db-backup.sh index fe73946bd..8abd933c6 100755 --- a/scripts/import-latest-db-backup.sh +++ b/scripts/import-latest-db-backup.sh @@ -6,18 +6,18 @@ source .env if [ -z $PATH_TO_BACKUPS ]; then - echo "please add 'PATH_TO_BACKUPS=/your/backups/root/directory' in .env at the root of the project in order to run this script" + echo "please add 'PATH_TO_BACKUPS=/your/backups/directory' in .env at the root of the project in order to run this script" exit fi -# Download last available backup, provided you already ran `make build` once. -echo "Downloading last available backup..." -( cd $PATH_TO_BACKUPS && make download ) -echo "Download is over." +# Download last available backup +# rclone copy --max-age 24h --progress communaute:/encrypted-backups ./backups +echo "please rclone the last db backup to $PATH_TO_BACKUPS" # Get the latest backup filename and path -DB_BACKUP_NAME=$(ls $PATH_TO_BACKUPS/backups | tail -n1) -DB_BACKUP_PATH=$PATH_TO_BACKUPS/backups/$DB_BACKUP_NAME +DB_BACKUP_NAME=$(ls $PATH_TO_BACKUPS | tail -n1) +echo "Going to restore $DB_BACKUP_NAME" +DB_BACKUP_PATH=$PATH_TO_BACKUPS/$DB_BACKUP_NAME echo "Going to inject DB_BACKUP_PATH=$DB_BACKUP_PATH" docker cp $DB_BACKUP_PATH commu_postgres:/backups