Last active
May 9, 2017 20:17
-
-
Save ale10257/d0c2609d48578d45a23599115149d662 to your computer and use it in GitHub Desktop.
backup sites & DB
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
#!/bin/bash | |
DATE=`/bin/date '+%d.%m.%Y'` | |
DB_PASSWD=passwd | |
USERS=$1 | |
cnf=$2 | |
mkdir ~/backup | |
cp rsync_email_orig rsync_email | |
date >> rsync_email | |
echo "==============================================" >> rsync_email | |
while read line;do | |
IFS=";" | |
set -- $line | |
USER=$1 | |
SITES=$2 | |
DB=$3 | |
DB_USER=$4 | |
FILE_NAME=~/backup/backup_"$SITES"_"$DATE".zip | |
cd /var/www/$USER/public_html | |
mysqldump -u$DB_USER -p$DB_PASSWD $DB > $DB.sql | |
zip -r9 $FILE_NAME $SITES $DB.sql > /dev/null | |
rm ./$DB.sql | |
zip -T $FILE_NAME >> ~/rsync_email | |
echo "==============================================" >> ~/rsync_email | |
chown $USER:$USER $FILE_NAME | |
done < ~/$USERS | |
/usr/bin/ydcmd --config=/root/$cnf put --rsync ~/backup/ disk:/backup >> ~/rsync_email | |
/usr/sbin/ssmtp [email protected] < ~/rsync_email | |
rm -rf ~/backup | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment