Last active
November 19, 2016 23:49
-
-
Save fr34kyn01535/ff1a281f7421ccef0e87 to your computer and use it in GitHub Desktop.
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup:
Schedule:
crontab -l | { cat; echo "0 1 * * 5 wget https://gist.githubusercontent.com/fr34kyn01535/ff1a281f7421ccef0e87/raw/backup.sh -O - | dos2unix | bash"; } | crontab -