This script will keep six daily, three weekly and three monthly rsync hardlinked backup of /etc, /home, /var/www and /root. It will also create a gzipped MySQL dump of the whole server inside each backup.
You must have already have public key access to the remote user.
Hardlink support will reduce usage space dramatically. More information on hardlinks
Run the following:
bash -c "$(wget -qO - 'gist.githubusercontent.com/mrl22/f64b8ea3e8cf4f30db7d382a13d1eeeb/raw/backup.sh')" '' -b remoteserver.com -u backupuser
or set it up in a cronjob:
0 2 * * * bash -c "$(wget -qO - 'gist.githubusercontent.com/mrl22/f64b8ea3e8cf4f30db7d382a13d1eeeb/raw/backup.sh')" '' -b remoteserver.com -u backupuser
Make sure to change the options:
-b = The host or IP of the remote SSH/Rsync Server. -u = The user name on the remote server.
for dir in $(ls|egrep -i '^backup\.(daily|weekly|monthly)'); do echo -n "$dir : "; cat "$dir/backup.txt"; done;