Add an update for awscli. Restore the backtracking paths.

This commit is contained in:
Ivaylo Novakov 2021-10-19 17:10:31 +02:00
parent b6a165cb28
commit 96a85e3ec4
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
1 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,8 @@
#!/bin/bash #!/bin/bash
# First of all, let's pamper awscli because Python is so special:
pip3 install --upgrade awscli
BACKUP=$1 BACKUP=$1
if [[ $BACKUP == "" ]]; then if [[ $BACKUP == "" ]]; then
echo "No backup name given. It should look like '2020-01-29'." echo "No backup name given. It should look like '2020-01-29'."
@ -89,18 +92,17 @@ cd $csd/..
# Get the backup from S3: # Get the backup from S3:
aws s3 cp $S3_BACKUP_PATH/$BACKUP/mongo.tgz mongo.tgz aws s3 cp $S3_BACKUP_PATH/$BACKUP/mongo.tgz mongo.tgz
# Prepare a clean `to_restore` dir: # Prepare a clean `to_restore` dir:
rm -rf docker/data/mongo/db/backups/to_restore rm -rf $csd/../docker/data/mongo/db/backups/to_restore
mkdir -p docker/data/mongo/db/backups/to_restore mkdir -p $csd/../docker/data/mongo/db/backups/to_restore
# Decompress the backup: # Decompress the backup:
tar -xzf mongo.tgz -C docker/data/mongo/db/backups/to_restore tar -xzf mongo.tgz -C $csd/../docker/data/mongo/db/backups/to_restore
rm mongo.tgz rm mongo.tgz
# Restore the backup: # Restore the backup:
# The name of the backup is not `mongo` due to the way we're creating it, # The name of the backup is not `mongo` due to the way we're creating it,
# it's $BACKUP. # it's $BACKUP.
docker exec mongo \ docker exec mongo \
mongorestore --drop \ mongorestore -- drop\
mongodb://$SKYNET_DB_USER:$SKYNET_DB_PASS@$SKYNET_DB_HOST:$SKYNET_DB_PORT \ mongodb://$SKYNET_DB_USER:$SKYNET_DB_PASS@$SKYNET_DB_HOST:$SKYNET_DB_PORT \
/data/db/backups/to_restore/$BACKUP /data/db/backups/to_restore/$BACKUP
# Clean up: # Clean up:
rm -rf docker/data/mongo/db/backups/to_restore rm -rf $csd/../docker/data/mongo/db/backups/to_restore
cd -