diff --git a/scripts/db_backup.sh b/scripts/db_backup.sh index 14f7abb1..32e042ce 100755 --- a/scripts/db_backup.sh +++ b/scripts/db_backup.sh @@ -27,26 +27,6 @@ fi # Take the current datetime: DT=$(date +%Y-%m-%d) -### COCKROACH DB ### -echo "Creating a backup of CockroachDB:" -# Check if a backup already exists: -totalFoundObjects=$(aws s3 ls $S3_BACKUP_PATH/$DT --recursive --summarize | grep "cockroach" | wc -l) -if [ "$totalFoundObjects" -ge "1" ]; then - echo "Backup already exists for today. Skipping." -else - # Create a cockroachdb backup: - docker exec cockroach \ - cockroach sql \ - --host cockroach:26257 \ - --certs-dir=/certs \ - --execute="BACKUP TO '$S3_BACKUP_PATH/$DT/cockroach/?AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY';" - if [[ $? > 0 ]]; then - echo "Creating a CockroachDB backup failed. Skipping." - else - echo "Successfully backed up CockroachDB." - fi -fi - ### MONGO DB ### echo "Creating a backup of MongoDB:" # Check if a backup already exists: @@ -73,3 +53,23 @@ else fi docker exec mongo rm -rf /data/db/backups/$DT fi + +### COCKROACH DB ### +echo "Creating a backup of CockroachDB:" +# Check if a backup already exists: +totalFoundObjects=$(aws s3 ls $S3_BACKUP_PATH/$DT --recursive --summarize | grep "cockroach" | wc -l) +if [ "$totalFoundObjects" -ge "1" ]; then + echo "Backup already exists for today. Skipping." +else + # Create a cockroachdb backup: + docker exec cockroach \ + cockroach sql \ + --host cockroach:26257 \ + --certs-dir=/certs \ + --execute="BACKUP TO '$S3_BACKUP_PATH/$DT/cockroach/?AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID&AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY';" + if [[ $? > 0 ]]; then + echo "Creating a CockroachDB backup failed. Skipping." + else + echo "Successfully backed up CockroachDB." + fi +fi