Created
November 3, 2021 09:33
-
-
Save paulknulst/4af45079b2b935de416aca8f01e15278 to your computer and use it in GitHub Desktop.
zip/encrypt (with pass from env) db backups within folder and upload resulting file to gcp using stored credentials on system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TIME=$(date +%Y-%m-%d) | |
HOST=$(hostname) | |
BACKUPSAVEPATH=/root/backups_encrypted/ | |
BACKEDUPFILE=$BACKUPSAVEPATH/db-backups-$HOST-$TIME.enc | |
TARGET=gs://f1nalboss-db-backups/ | |
cd /root/backups/db || exit 1 | |
if [ -z "$(ls -A .)" ]; then | |
exit 1 | |
else | |
tar czf - . | openssl enc -e -aes-256-cbc -pbkdf2 -iter 100000 -salt -out $BACKEDUPFILE -pass env:PASS | |
/root/google-cloud-sdk/bin/gsutil -m rsync -r $BACKUPSAVEPATH $TARGET || exit 1 | |
rm -rf /root/backups/db/* | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment