Created
May 8, 2018 20:31
-
-
Save giuliocalzolari/c78ca1a8b154502c4009cb3a7d5f871e to your computer and use it in GitHub Desktop.
backup.sh
This file contains hidden or 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 | |
export AWS_DEFAULT_PROFILE=zzzzzz | |
BUCKET=xxxxx | |
# DIRS="$HOME/.bash_profile $HOME/.gitconfig $HOME/.aws $HOME/.ssh $HOME/.bashrc $HOME/.gnupg $HOME/.bash_history" | |
DIRS="$HOME/.bash_profile $HOME/.gitconfig $HOME/.aws $HOME/.ssh $HOME/.bashrc $HOME/.gnupg $HOME/.bash_history $HOME/git" | |
echo "Backup $DIRS.." | |
tar czf $HOME/backup.tgz $DIRS | |
echo "Encryption.." | |
gpg --symmetric --cipher-algo aes256 -o $HOME/backup.tgz.gpg $HOME/backup.tgz | |
echo "Transferring to s3.." | |
aws s3 cp $HOME/backup.tgz.gpg s3://$BUCKET/backup.tgz.gpg | |
EXS=$? | |
S3DIM=$(aws s3 ls $BUCKET | awk '/backup.tgz.gpg/{print $3}') | |
LODIM=$(ls -l $HOME/backup.tgz.gpg | awk '{print $5}') | |
[ "x$S3DIM" != "x$LODIM" ] && echo "WARNING! dimensions do not match" | |
[ $EXS -eq 0 ] && rm $HOME/backup.tgz $HOME/backup.tgz.gpg | |
echo "Finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment