... | ... | @@ -55,4 +55,18 @@ The restore can be done with command `pg_restore`. For instance |
|
|
pg_restore dewilde_backup_Monday
|
|
|
```
|
|
|
|
|
|
A more professional version of this is the following script that will get the backup from S3 cloud storage based on a date. Please adjust exported variables first before running this script.
|
|
|
|
|
|
```bash
|
|
|
echo Example usage: $0 acc dm 20240122
|
|
|
SOURCE_ENV=$1 # e.g. acc
|
|
|
TARGET_ENV=$2 # e.g. tst
|
|
|
DATE=$3 # e.g. 20240122
|
|
|
AWS_OPTS="--endpoint-url https://eu2.contabostorage.com"
|
|
|
mkdir -p /tmp/backup-restore
|
|
|
cd /tmp/backup-restore
|
|
|
aws $AWS_OPTS s3 cp s3://backups/wyatt_${SOURCE_ENV}_db/wyatt_${SOURCE_ENV}_db_${DATE}.zip .
|
|
|
unzip wyatt_${SOURCE_ENV}_db_${DATE}.zip # enter password
|
|
|
docker cp backups/wyatt_${SOURCE_ENV}_db_${DATE}.db wyatt_${TARGET_ENV}_db://tmp/wyatt.db
|
|
|
docker exec -t wyatt_${TARGET_ENV}_db pg_restore --verbose -Fc --clean -U wyatt -d wyatt /tmp/wyatt.db
|
|
|
``` |
|
|
\ No newline at end of file |