Rsnapshot backups en GNU/Linux (3/3)

Backups with rsnapshot via ssh

Rsnapshot of ubuntu server
Scheme made with DIA diagram editor. The images of the servers are openclipart.

Rsnapshot backups en Gnu/Linux. (1/3)
Rsnapshot backups en Gnu/Linux. (2/3)
Rsnapshot backups en Gnu/Linux. (3/3)

This article will discuss how to backup incremental and automated with rsnapshot via the protocol ssh.


Server1 which we want back several folders within the server2.


Hostname : Server1
Operating System : Ubuntu server 12.04

Folders to save:
/etc /

Copies save: Copies are stored every day the last 7 days
Copies are stored weekly fan 4 weeks
Copies are stored per month the last six months
Copies are stored at the last year 5 years old

Users with permission to access the folders to save
User: user1
Password: user1pass


Hostname : Server2
Operating System : Ubuntu server 12.04
Backup Folder: /backups/

Set to logging by ssh public key.

Install SSH Server on Server1 and Server2

We installed the ssh server for backup server2 can log on to get the files to save.

In the server1:

 user1 @ server1 $ sudo apt-get install openssh-server


In server2:

 user2 @ server2 $ sudo apt-get install openssh-server


We generate keys from server2 user to conduct backups.

user2 @ server2 $ ssh-keygen 
 Generating public/private rsa key pair.  Enter file in which to save the key (/home/user2/.ssh/id_rsa):  Created directory '/home/user2/.ssh'.  Enter passphrase (empty for no passphrase):  Enter same passphrase again:  Your identification has been saved in /home/user2/.ssh/id_rsa.  Your public key has been saved in /home/user2/.ssh/  The key fingerprint is:  75:0a:64:2and:16:d9:53:25:80:f7:f0:74:a0:ff:e6:e2 user2 @ server 2 The key's randomart image is:  +--[ RSA 2048]----+  | .++O   O. |  | o == .... |  | the.   * ... |  | . . +and |  | S o |  | . |  | the |  | .the |  | .E.. |  +-----------------+

Press enter on all questions it is advisable not to passphrase do not ask for the key at each connection.

The command creates two keys

Private Key in: /home/user2/.ssh/id_rsa

Public Key in: /home/user2/.ssh/


Copy the public key from the server1 server2.

user2 @ server2 $ ssh-copy-id -i /home/user2/.ssh/ user1@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is 27:51:45:35:8b:97:2d:b6:60:1and:8d:55:c0:2b:24:45.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
user1@'s password:


We ask for the password of user1 at server1 and we put.

 Now try logging into the machine, with "ssh 'user1@'", and check in:
 to make sure we haven't added extra keys that you weren't expecting.

We found that logs automatically creating a ssh connection

user2 @ server2 $ ssh user1@

If logs correctly without asking the key everything is correct.

We can do this with every team we want to save.

Configuring rsnapshot on server2 for remote backup.

All settings are performed in the server2 just as in the manual rsnapshot locally only change the backup section where we will put the following lines. We server1 to keep copies of this equipment in a folder called / backup/servidor1 /

$ sudo nano /etc/cron.d/rsnapshot
backup user1@ servidor1/
backup user1@ / servidor1 /
backup user1@ / log / servidor1 /

In this section we could add data from all those teams that want to perform the backup.

To verify the correct configuration of rsnapshot run the following command

user2 @ server2 $ sudo rsnapshot configtest 
Syntax OK

When returns Syntax OK is that the configuration is correct.

We found that works by performing the first backup with the command.

user2 @ server2$ sudo rsnapshot daily


We found that the folder is created /backup/daily.0/server1 / binders containing home, y etc var / log we wanted to save.

user2 @ server2 $ sudo ls -la /backup/daily.0/localhost

Hope you liked these manuals for backup in linux

Any comments received will be welcome thank you very much for reading this article.

Rsnapshot backups en Gnu/Linux. (1/3)
Rsnapshot backups en Gnu/Linux. (2/3)
Rsnapshot backups en Gnu/Linux. (3/3)

For this article I created based on information from these pages.

About Ignacio Alba Obaya

Microcomputer and Technical Training for Employment. Lover of new technologies. Manager GNU / Linux and Windows.


  1. Pingback:

Leave a Reply