Thursday, 6 March 2014

3 simple methods of remote backuping

There are many methods, which one can use when backuping a linux box. But there are few ways to do it very simple, without need of using third-party software. The first method, I propose, is FTP, the second – SCP, and the third is, of course, RSYNC. Every of them has advantages and disadvantages, which I'm going to describe in this article.

It is a great idea to use all of these methods simultaneously. It will strongly decrease the risk of data lost in the situation, when your main storage and the backup will fail in the same time.


This is not very effective way of backuping, but many providers offer FTP storage included in a dedicated server offer. So why do not use it?

Everything can be done with the only one command:

tar -cf - /path/to/directory /path/to/directory/2 | ncftpput -u USER -p PASS -c HOST backup.tar

The first element, tar -cf, will pack given directories to the tar archive on the fly. And the next, ncftpput, will put this archive on you FTP storage. Of course, paths, and USER/PASS/HOST variables should be replaced by your own data.

Remember, that FTP transfer is not encrypted, so don't use this method when backuping across the internet. It is useful only in the safe, local network.


This method is very similar to FTP, but uses different protocol and offers a higher security level, hence it is useful also in the remote backup. SCP gives you encrypted transmission and logging on using RSA key.

First, you should put your public RSA key in ~/.authorized_keys2 to your backup server. Next, check if ssh connection works properly.

Now, let's make the tar archive from directories, you want to backup:

tar -zcf backup.tar.gz /path/to/directory /path/to/directory2

Next, send it to your backup server:

scp backup.tar.gz USER@HOST:

That's all.


The last method, I propose, is RSYNC. The biggest advantage of this way of backuping is that RSYNC is able to send only files, which were modified. It can significally increase a speed of the data transfer. The usage is similar to SCP. First, you should generate RSA keys, as stated above, and than use this command:

rsync -halq --delete-before --perms --ignore-errors /path/to/directory USER@HOST:backup

This command will replicate given directory tree to the remote directory backup.

What to do else?

At the end, you should automate this process by making simple bash scripts and adding them to the crontab. Always remember to periodically check if your backup scripts are working properly.