From 281fb06bb9f4ee628fb409e7cf7505c5aef70df9 Mon Sep 17 00:00:00 2001 From: Manuel Mendoza Date: Wed, 8 Aug 2018 11:19:04 +0200 Subject: [PATCH] added functionality to restore latest backup --- restore.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/restore.sh b/restore.sh index 5eef2ee..1a98554 100755 --- a/restore.sh +++ b/restore.sh @@ -6,6 +6,11 @@ DB_NAME=`python /usr/local/bin/mongouri database` IFS="," for BACKUP_NAME in $BACKUP_NAMES do + # Get latest backup + if [ "$BACKUP_NAME" == "latest" ]; then + BACKUP_NAME=$(aws s3 ls "s3://${S3_BUCKET}/${S3_PATH}/" | tail -1 | awk '{print $NF}') + fi + # Download backup aws s3 cp "s3://${S3_BUCKET}/${S3_PATH}/${BACKUP_NAME}" "/backup/${BACKUP_NAME}" # Decompress backup with progress