≡ Menu

How To Backup Remote Linux Host Using rsnapshot rsync Utility

Ubuntu, Debian, Linux Remote BackupIn the previous article we reviewed how to backup local unix host using rsnapshot utility.

In this article, let us review how to backup remote Linux host using this utility.

1. Setup Key Based Authentication

As we’ve explained earlier setup the key based authentication as explained either in ssh-keygen and ssh-copy-id article or openSSH article.

[root@local-host]# ssh-keygen

[root@local-host]# ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host

2. Verify the password less login between servers

Login to the remote-host from local-host without entering the password.

[root@local-host]# ssh remote-host
Last login: Sun Mar 15 16:45:40 2009 from local-host


3. Configure rsnapshot and specify Remote Host Backup Directories

Define your remote-host destination backup directories in /etc/rsnapshot.conf as shown below. In this example,

  • root@remote-host:/etc – Source directory on the remote-host that should be backed-up. i.e remote backup destination directory.
  • remote-host-backup/ – destination directory where the backup of the remote-host will be stored. Please note that this directory will be created under local-host /.snapshots/{internal.n}/ directory as shown in the last step.
# vi /etc/rsnapshot.conf

backup  root@remote-host:/etc/  remote-host-backup/  exclude=mtab,exclude=core

4. Test rsnapshot Configuration

Perform configuration test to make sure rsnapshot is setup properly and ready to perform Linux rsync backup.

# rsnapshot configtest
Syntax OK

5. Add Crontab Entry for rsnapshot

Once you’ve verified that the rsync hourly and daily backup configurations are setup properly in the rsnapshot cwrsync utility, it is time to set this puppy up in the crontab as shown below.

# crontab -e
0 */4 * * * /usr/local/bin/rsnapshot hourly
30 23 * * * /usr/local/bin/rsnapshot daily

Check out Linux crontab examples article to understand how to setup and configure crontab.

6. Manually test the remote-host backup once

[root@local-host]# /usr/local/bin/rsnapshot hourly

[root@local-host]# ls -l /.snapshots/hourly.0/
total 8
drwxr-xr-x 3 root root 4096 Jul 22 04:19 remote-host-backup
drwxr-xr-x 3 root root 4096 Jul 13 05:07 localhost

[root@local-host]# ls -l /.snapshots/hourly.0/remote-host-backup/
total 4
drwxr-xr-x 93 root root 4096 Jul 22 03:36 etc

Troubleshooting Tips

Problem: rsnapshot failed with ERROR: /usr/bin/rsync returned 20 as shown below.

[root@local-host]# /usr/local/bin/rsnapshot hourly
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(260)
rsnapshot encountered an error! The program was invoked with these options:
/usr/local/bin/rsnapshot hourly
ERROR: /usr/bin/rsync returned 20 while processing copyman@

Solution: This typically happens when the users who is performing the rsnapshot (rsync) doesn’t have access to the remote directory that you are trying to backup. Make sure the remote host backup directory has appropriate permission for the user who is trying to execute the rsnapshot.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Marko September 17, 2009, 2:32 pm

    I am able to backup files and folders from Debian machine to windows machine.
    I would like to know how to backup the entire hdd from Debian machine to usb-hdd atached to windows machine?
    It would be nice to know how to do this.
    How to do daily snapshots of linux hdd – I mean exact copy of linux hdd.
    Is it possible to create a snapshot and then just incremental backup to that snapshot?
    I will crate webpage with drawing of my configuration if someone is intresting in giveing any advice about my questions…


  • Marko September 18, 2009, 3:23 am

    So here is web page where I made a drawing of my problem:

  • Patrick January 7, 2011, 11:28 am

    I haven’t understood why I need to add “hourly” to manually test if rsnapshot is correctly configured.

    # /usr/local/bin/rsnapshot hourly

    I just want to do it once, and not hourly…

    Also, if I run this command, is it going to run every hour without stopping ? It is not clear.


  • Peter Snow January 27, 2012, 8:59 pm

    I thought your other tutorials were great. I followed many of them on first reading.

    Unfortunately though, this one seems more challenging to read. It really needs a lot of clarification. For example, you don’t go into enough detail for me, concerning which machine the program should be installed on (actually, I only assumed that there was a program to install and stumbled on how to do it), and which machine the commands should be run on and from which and to which machine the backup is coming and what is the destination machine!

    Your rsnapshot.conf seemed to have only one line in it, where as mine had loads. Do I replace all of mine with your ONE? Your one line looked more like a shell command than a config file line? Doesn’t make any sense at all.

    Maybe after studying carefully for an hour I could unravel this and get it working, but if rewritten to the standard of your other tutorials, I could probably follow it in ten minutes.

    Overall, I love your website and find it very useful. Please don’t be discouraged!


  • Adam May 25, 2012, 11:37 am

    Is it possible to do this if the remote server is not using the default port for connection, i.e lets say you can only connect to the remote server if you use port 12345. Where would we define the port?

  • Travis December 29, 2014, 1:03 pm


    Yes, you can do that if you define the port in the rsnapshot.conf file.