Backup your data on a backup hdd with rsync
This tutorial has been requested by one of our readers that was having trouble with the default cPanel backup script.
It is something well known that the cPanel backup script takes a long time to finish and consumes a lot o resources.
This is not a big problem if you have 100 accounts on the server but if you have 1000 you will see what I am talking about.
The backup script that I am suggesting uses rsync and will update only the files that are changed since the last backup. This will greatly reduce the backup time and the load on the server.
For this script to work you have to have a second hdd with a size identical or greater then your main hdd.
In this example I will backup the hole hdd but you can of course backup only /home or anything you like.
To better protect the data on the backup hdd, this hard-disk will be mounted as read-only for the majority of time and will be switched to read/write only when the backup script is running .
I recommend running the script once a week or once a day.
If you want to run it once a week go to /etc/cron.weekly/
cd /etc/cron.weekly/
Now we will create the backup script
nano backup
Paste into this file the fallowing
#!/bin/bash
mount -o remount,rw /backups
rsync -av –delete –exclude=/backups / /backups
mount -o remount,ro /backups
This will backup “/” to” /backups”, replacing only the changed files since the last backup. It will also mount /backups in read/write mode first and after the backup is finished it will mount it in read-only mode.
Hope it helps !
PS: Remember that this is just a basic backup script. There are many enhancements that can be done and if you have some creative ideas please leave a comment with your suggestions.
Also please note that this does not replace the need for a fault tolerant solution such as a RAID matrix.
If you enjoyed this post, make sure you subscribe to my RSS feed!
- December 22nd

















This post pertaining to your data on a backup hdd with rsync | cPanelConfig - cPanel server configuration guide. is intriquing.
Hi,
How would you say this works with mysql databases on the server? Am I going to have problems with only rsyncing those or would you advise to cron a mysqldump as well?
I’ve been using MySQL dump to backup databases offsite for a while, but I’d like to do something similar to what you’re describing via SSH rather than to another drive in the same server. How hard would it be to mount via SSH instead of to a local drive?
And what other folders need to be backed up? /etc/, /var/, etc?
Hi Ryan,
Sure you can easily configure it to backup to a remote server. For information check rsync documentation.
Please note that backing up InnoDB tables can’t be done by rsync-ing the files and you still have to do a dump of the database first.
cewfipq gwzbch evmydk vpiykq ebxtcny mcwrdezpb atycbidvk
Is it possible on windows servers ??