Last active
October 16, 2015 03:31
-
-
Save sr2ds/219b84d48f5d7f87f211 to your computer and use it in GitHub Desktop.
Simple Backup Linux Server with recicle (FileSystem + Mysql)
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 | |
# Include this file on crontab | |
# | |
PASS="#123{msaoi0921%" | |
# Create Dir for backups | |
mkdir -p /bkp/tmp >/dev/null 2>&1 | |
mkdir -p /bkp/www >/dev/null 2>&1 | |
mkdir -p /bkp/db >/dev/null 2>&1 | |
mkdir -p /bkp/conf >/dev/null 2>&1 | |
data=`date +%d-%m-%Y-%H-%M` | |
cd /bkp/tmp/ | |
# Duplicate this line for more dumps | |
echo "Backup Bancos de Dados" | |
mysqldump -p$PASS esparta > esparta.SQL | |
mysqldump -p$PASS membros > membros.SQL | |
tar cjvf db-$data.tgz * | |
rm -rf /bkp/tmp/*.SQL | |
mv * /bkp/db/ | |
echo "Backup Diretorios" | |
tar cjvf /bkp/www/www-$data.tgz /var/www/ > /dev/null | |
tar cjvf /bkp/conf/conf-$data.tgz /etc > /dev/null | |
echo "Removendo antigos" | |
# Erase 5 backups more olds | |
find /bkp/db/ -ctime +5 -exec rm -f {} \; | |
find /bkp/www/ -ctime +5 -exec rm -f {} \; | |
find /bkp/conf/ -ctime +5 -exec rm -f {} \; | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment