Webserver Backup Script (MySQL / Files / ...)
This script creates an archive from your webserver.
It copies your website's files, the configuration of the system and it even dumps your MySQL database into a file.

First, create this script:
vi /serverbackup.sh
After, give it permission to be executed:
chmod +x /serverbackup.sh
Now, copy the following code inside:

tar -cvzf /serverbackup/backup-files.tar.gz /srv/*
tar -cvzf /serverbackup/backup-config.tar.gz /etc/* /usr/local/php5 /usr/local/apache2
mysqldump -h localhost -u root -pPASSWORD --all-databases > /serverbackup/backup-mysqldump.sql
gzip /serverbackup/backup-mysqldump.sql
tar -cf /serverbackup/backup.tar /serverbackup/backup-files.tar.gz /serverbackup/backup-mysqldump.sql.gz /serverbackup/backup-config.tar.gz
rm /serverbackup/backup-files.tar.gz
rm /serverbackup/backup-mysqldump.sql.gz
rm /serverbackup/backup-config.tar.gz

Attention: Replace PASSWORD with the passwort of your MySQL root user.
Also replace the different paths to fit your server's setup.
admin / Dec 04, 2005
2004 - 2017 / lookass.ch