Skip to content

Instantly share code, notes, and snippets.

@fr34kyn01535
Last active November 19, 2016 23:49
Show Gist options
  • Save fr34kyn01535/ff1a281f7421ccef0e87 to your computer and use it in GitHub Desktop.
Save fr34kyn01535/ff1a281f7421ccef0e87 to your computer and use it in GitHub Desktop.
NAME=$(hostname -f)
TIMESTAMP=$(date +%s)
echo Starting backup on $NAME
mkdir -p ~/backuptmp/
echo Getting iptables...
iptables-save >~/backuptmp/iptables
echo Getting Webserver...
rsync -rq /var/www ~/backuptmp/www
echo Getting MySQL...
rsync -rq /etc/mysql ~/backuptmp/mysql
mysqldump --all-databases -u mysqldump > ~/backuptmp/mysqldump.sql
echo Getting Lets Encrypt certificates...
rsync -rq /etc/letsencrypt/live/ ~/backuptmp/letsencrypt
echo Getting Apache2 config...
rsync -rq /etc/apache2 ~/backuptmp/apache2
echo Getting Nginx config...
rsync -rq /etc/nginx ~/backuptmp/nginx
echo Getting Jenkins home...
rsync -rq /var/lib/jenkins ~/backuptmp/jenkins
echo Getting Postfix config...
rsync -rq /etc/postfix ~/backuptmp/postfix
rsync -rq /var/mail ~/backuptmp/mail
cd ~/backuptmp/
echo Compressing...
zip -rq backup.zip ./
echo Encrypting...
gpg -r "fr34kyn01535" --batch --no-tty --trust-model always -e backup.zip
echo Sending...
mv ~/backuptmp/backup.zip.gpg ~/backuptmp/$TIMESTAMP.zip.gpg
ftp-upload -h dagobah.bam.yt -d /backup/$NAME ~/backuptmp/$TIMESTAMP.zip.gpg
echo Cleaning up...
rm ~/backuptmp/ -R
@fr34kyn01535
Copy link
Author

fr34kyn01535 commented Feb 11, 2016

Setup:

apt-get install zip pgp dos2unix ftp-upload -y
wget -O - https://keybase.io/fr34kyn01535/key.asc | gpg --import

Schedule:
crontab -l | { cat; echo "0 1 * * 5 wget https://gist.githubusercontent.com/fr34kyn01535/ff1a281f7421ccef0e87/raw/backup.sh -O - | dos2unix | bash"; } | crontab -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment