Do you have disk storage problems on the server? Or, is the server backup eating up more disk space?
Moving backup to another location would be the quickest possible solution here.
Luckily, cPanel rsync backup option helps to save disk space by placing backup data to a remote server.
That’s why, at Bobcares, we often get requests from our customers to set up rsync backup in WHM/cPanel as part of our Server Management Services.
Today, we’ll see how our Support Engineers set up cPanel rsync backup and fix the related errors.
What is Rsync?
Rsync is a command that is used to copy data, make backups, and migrate hosts. More clearly, with the help of rsync, we can efficiently transfer and synchronize files between the servers. It’s even possible to copy data to an external hard drive and across networks.
Moreover, rsync uses compression during data transfer. Thus, it offer benefits in time as well as bandwidth.
Fortunately, there are multiple ways to make use of rsync to take a cPanel server backup. Let’s see the top methods that our Support Engineers use.
1. How we rsync via backup script
1. To backup with rsync, we install rsync utility on to the servers and set up a password less key based authentication for ssh.
2. When we’re done setting up rsync and ssh keys, we create custom script at /scripts/postcpbackup
3. Then we add the following code that contains the exact rsync command.
#!/bin/sh /usr/bin/rsync -va --progress --delete --rsh='ssh -p22' /backupdirect remoteuser@IP_OR_FQDN:~/
Here, the ssh runs on port 22 of the server. We make adequate changes when ssh listens on alternate port. Again, we give correct remote login details and set the directory to store the backup.
4. We, then make the script executable with the following code.
chmod +x /scripts/postcpbackup
5. After that we login to WHM and go to Main >> Backup >> Configure Backup to configure the backup plan.
6. Next, we set up Backup Destination to a local directory. For example “/backupdirect”.
7. Finally, we enable the option “Execute Pre/Post Backup Script” and set it as
/scripts/postcpbackup and save.
2. How we configure Rsync backup settings in WHM
1. Initially, we login into WHM control panel.
2. We go to Home > Backup > Backup Configuration.
3. Then we select Additional Destinations and to save the backups to additional destinations.
4. next, we select Destination Type as Rsync and click on create new destination.
5. After that, we fill the following field too.
- Destination Name
- Transfer System Backups to Destination: Select this checkbox to transfer the backup to the destination.
- Backup Directory.
- Remote Host: we enter the hostname or IP address of the remote server.
- Port: By default, we use port 22 for Rsync communication to destinations.
- Remote Account Username: we enter the account username on the remote server.
- Authentication Type: we select either Key Authentication Options or Password Authentication Options.
6. At last, we click the Save Configuration button.
How we fixed rsync backup related errors in cPanel
From our experience in managing servers, we’ve seen customers facing problems while backup with rsync in cPanel. Let’s take a closer look at how our Support Engineers fixed the problems.
1. Problem with user permissions
Recently one of our customers reported an error while taking rsync backup to a remote server. He got an error like
" Validation for transport “bk-srv2” failed: Could not upload test file: child exited with code 1".
On checking, our Support Engineers found that the error was due to user permissions. The user added to access the remote server didn’t have permissions to read/write data on the VPS.
Therefore, we fixed the problem by correcting the permission of the user.
Also, this error can also happen when cPanel license expires or due to problems related to the cPanel License.
2. Missing command
Similarly, another customer came up with a problem while rsync the backup between the local server and the remote server. He got an error as follows. The error said,
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]
Then, our Support Engineers found that the rsync was not installed on the remote server. But, it was already installed in the source server.
Therefore, we installed the rsync command on the remote server and that fixed the error.
[Having trouble while backup with rsync in cPanel? We’ll fix it for you.]
In short, one of the solutions to avoid disk storage problem is cPanel rsync backup to a remote server. Today, we saw how our Support Engineers set up rsync backup in WHM and fix related errors.