Skip to content

Commit

Permalink
update script to restore last backup, using rcloned dump
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 26, 2023
1 parent 1885954 commit c591813
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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
14 changes: 7 additions & 7 deletions scripts/import-latest-db-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c591813

Please sign in to comment.