Ubuntu – easily take a snapshot and restore it with rsnapshot

I had to do this when I had a server setup with a lot of stuff, but it couldn’t be kept live for some time, so we tried to find a solution to backup and keep all the things for a future deployment without the need to go through all the painful installations and configurations.

As the server was a VPS and we had SSH access, I researched and stumbled upon this neat little tool: Rsnapshot

(The rsnapshot website: https://rsnapshot.org/) It seemed to do the trick, so I gave it a try.

So, on the source server, I logged in via SSH, then installed snapshot:

sudo apt-get install rsnapshot

Then you need to check/edit the config file:

vi /etc/rsnapshot.conf

In there, different from the web article, there aren’t “daily, weekly, monthly“, but “alpha, beta, gamma“, which I presume do the same job, but they changed the names in the meantime…

retain  alpha   6
retain  beta    7
retain  gamma   4
#retain delta 3

I left everything else the same, then did the test command, which was fine.

Then ran the command for instant backup:

sudo rsnapshot alpha

Then everything should be saved where the setting path was: /var/cache/rsnapshot/alpha.0

So the main areas that are needed to be stored to keep pretty much all the server content (users, web pages, accounts etc) are:

backup  /home/          localhost/
backup  /etc/           localhost/
backup  /usr/local/     localhost/

How to restore the backup on another server

Now we need to restore it on the other server we need to populate it with those files. So we need to ssh into the other server and then just scp them from the remote backup:

cd /
scp -r root@remote_ip:/var/cache/rsnapshot/alpha.0/localhost/* .   

In other words, you copy “-r” (recursive) all the folders from the remote location “/var/cache/rsnapshot/alpha.0/localhost” authenticated with “root@remote_ip” (you’ll be asked for pass) to the current local path (which is the root /)

So all the backup files will be just poured in the exact respective folders on the local server, which should do the trick.

Please Login to Comment.