Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save giuliocalzolari/c78ca1a8b154502c4009cb3a7d5f871e to your computer and use it in GitHub Desktop.
Save giuliocalzolari/c78ca1a8b154502c4009cb3a7d5f871e to your computer and use it in GitHub Desktop.
backup.sh
#!/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