Sometimes, having a very busy server is bad rather than good!  Yes, it’s good that if you have a busy server since there are more web traffic and more activities on your server, but the bad news is that it has to do everything with your server being busy.  What worse is that when you need to backup your busy server using whatever method you knew, and you find out that your server load is skyrocketing since backing up a huge server is a taxing process.  There are several ways you can make things gentler for your server load when you are backing up.  One of the way is to use rsync along with ionice.  Cpanel server can be backed up by generating backup copies of cpanel’s files and structure but skip the home directory so administrator (i.e., you) can rsync home directories of users later as backup.

If you’re not familiar with ionice, rsync, cpanel, and such jargons — I suggest you do some research on these tools first before you jump ahead with what you want to do with them.  Doing things blindly can severely destroy your servers!  Best of luck on your research…

Now, I’m going to list an example of how you can backup a huge server using rsync, and then I’ll show you how to backup a cpanel server using /scripts/pkgacct and how to restore cpanel server using /scripts/restorepkg.  Restoring home directories for users on each server using rsync is pretty much as how you learn to use rsync in the first place.

To use rsync for backing up is not a taxing process (i.e., overloading your server) but it can do better when you assign priorities and IO behavior to rsync command using ionice so the server load and the IO resource will be spent at a friendlier manner.  An example of this such as:

/usr/bin/ionice -c2 -n7 rsync -avz –exclude=/home/virtfs -e ssh /home user@user.server.tld:server1

You can [man ionice] in terminal without the square brackets to see more information on how to use ionice.   The example I give above using ionice at best effort which means — (This is the default scheduling class for any process that hasn’t asked for a specific io priority. Programs inherit the CPU nice setting for io priorities. This class takes a priority argument from 0-7, with lower number being higher priority. Programs running at the same best effort priority are served in a round-robin fashion.) — taken that quote directly from [man ionice].

So [ionice -c2 -n7] is best effort with priority 7.  The higher the priority number, the lower the priority for the process of such a command.

Looking at the rsync portion, you can see I use –exclude=/home/virtfs.  On some servers, there is a folder known as /home/virtfs which will always be generated dynamically by the server and such files aren’t needed to be backup, otherwise it would take a lot longer for the backup process to be finished — therefore I exclude that specific directory to be backed up by rsync.

Using -e for rsync command specifies which protocol you want to use, and in the case above, -e ssh means I use protocol ssh to transfer data between two servers.

-e ssh /home user@user.server.tld:server1 equals to backup files from home directory (i.e., /home) from one server to another server at specific address of user@user.server.tld:server1.

Obviously, you can use this knowledge with /etc/crontab or crontab -e to provide cron jobs for your server.  The automation process is sweet since it’s taking you out of the equation and allowing the server to automatically run those command lines at specified times that you want to specify.

Cpanel users can backup huge server in two steps.  First step is to use /script/pkgacct so it will recreate an account’s raw data such as structure and databases, but /script/pkgacct can also backup entire home directory which we want to avoid such thing by using –skiphomedir to skip the home directory so the server won’t be overloaded by a huge home directory of a specific user.

An example would be:  /scripts/pkgacct –skiphomedir user

Enter the command above in your terminal as root in the cpanel server that you want to back up.  When it’s finished, all you have to do is to — scp the-example-file (i.e., cpmove-username.tar.gz) to the new server (i.e., server you want to restore the backup).

Second step is to rsync the home directory of a user to a backup server.  Later, you can rsync the home directory from the backup server to a new server right after you have restore the user’s cpanel files (i.e., cpmove-username.tar.gz).

Two steps to restore cpanel server accounts:

First, we restore pkgacct file.  Example file name would be cpmove-user.tar.gz.  Move such file into new server.  Change to root.  Then do /scripts/restorepkg username.

Second, we rsync back the home directory of a user from backup server to the new server.  Example:  /usr/bin/ionice -c2 -n7 rsync -avz –exclude=/home/virtfs -e ssh /home user@user.server.tld:server1.  This time though, you execute this command line from a backup server, and the remote server would be the new server.

To see how well the tips above work out, you need to run [top] without the square brackets on both servers (i.e., the localhost and the remote server) to see where the server loads are at.