Backup
#!/bin/bash
# SET VARS
TODAY=`date +%Y%m%d-%H-%M`
USER="backup"
PASSWORD="BVB8LWbxmS5fYMeq"
OUTPUTDB="/backup/DBs/"
OUTPUTETC="/backup/etc_config/"
OUTPUTWWW="/backup/www/"
CONFIGPATH="/etc/"
WWWPATH="/var/www/"
# BACKUP etc
zip -9 -rq $OUTPUTETC$TODAY-etc.zip $CONFIGPATH
# BACKUP WEBSPACES
webspaces=`ls $WWWPATH`
for web in $webspaces; do
if [[ "$web" != "phpmyadmin" ]] ; then
echo "Backing up: $web"
zip -9 -rq $OUTPUTWWW$TODAY.$web.zip $WWWPATH$web
fi
done
# EXPORT EACH SQL DATABASE ...
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
echo "Dumping database: $db"
mysqldump -u $USER -p$PASSWORD --databases $db | gzip -c > $OUTPUTDB$TODAY.$db.sql.gz
fi
done
# HOUSEKEEPING
find /backup/ -type f -mtime +5 -exec rm {} \;
echo ' '
echo 'EXPORT DONE ...'
Sie haben neue Post in /var/mail/root.