How to install and configure rsnapshot for incremental backups

snapshot

The homework of backup It is essential to protect the information we have on our computers, although it is clear that one thing is to do it at home and quite another is to have to protect the data of a university or a company, where the volume of information is much greater and there is different responsibilities. Therefore, the need for powerful and versatile tools is much greater, although it is clear that these can also be used by any of us at home.

Now let's see how to install and configure rsnapshot for incremental backups, it is a tool that not only allows us to safeguard information in a safe and simple way but also does it very efficiently. An example of this we say is the fact that the space required for storage, no matter how we use it, it is slightly higher than a backup since then the only thing that is stored is a copy of those files that are modified. Another advantage of rsnapshot is that the backups are hard links to the previous backups, this as long as there have been no changes in the Backups Of course.

To use snapshot we have to fulfill some questions, and it is that it is a tool that in turn relies on others for its operation. For example, let's need rsync installed and also have access via SSH to the computer on which we are going to store our backups, that is, we must have installed SSH on both computers and configured the keys to be able to access without having to enter the password 'by hand'.

So, first of all we are going to configure this:

ssh-keygen -t rsa

Here SSH will ask us for the phrase, but since we are going to execute commands remotely we want 0 interaction so we are going to discard this by pressing the Enter / Enter key the 2 times that we are requested. At the end we will have 2 new files in ~ / .ssh: one is id_rsa and contains the private identification key, the other is id_rsa.pub and contains the public key. The latter is copied to the remote server using the ssh-copy-id command, which asks us for the password of the account on said server and then takes care of uploading and storing it in the proper way, that is, creating the corresponding directories and setting the permissions that are necessary:

# ssh-copy-id -i ~ / .ssh / id_rsa.pub user @ remote server

Then we install rsync and rsnapshot:

# sudo apt-get install rsync rsnapshot

Now we edit the rsnapshot configuration file to establish the directory in which we are going to make the backups:

# nano /etc/rsnapshot.conf

We modify the snapshot_root section to indicate where we will store the backups on the remote computer:

# snapshot_root / disk1 / backup

We establish the interval in which snapshot will perform its task (in this example, four times a day that is every six hours), and for this we remove the # in front of the one we are going to use, and modify it to taste, for example:

interval hourly 4

Now we establish the local folders that we are going to synchronize, for which we add them together with the 'backup' option:

backup / home / localhost /

backup / etc localhost /

It should be noted that the fields are separated by 'tabs', that is to say that after entering one we press the tab key, and so on. As well we can indicate which files we want to exclude from our backups, for which we use a line dedicated to each of them:

exclude_file /etc/rsnapshot.conf

exclude_file /etc/bashrc.conf

Then we save and finish this configuration, but luckily we have the possibility to check it by means of a parameter:

# rnapshot configtest

If all goes well we will receive a message saying 'Sintax OK'.

Another option is to run it in test mode, for which we enter:

# rsnapshot -t hourly

Finally, we simply have run rsnapshot, which we do by attaching the execution mode, which must match the interval we have used: hourly, daily, weekly or monthly.

In our case:

#rsnapshot hourly

We will see that within / disk1 / backup will be the folders /daily.0/localhost/home y daily.0 / localhost / etc, and within them will be the same contents as in the folders of the team that we wanted to protect. That's it, and thanks to snapshot from now on we can count on incremental backups in our system.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.