Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

Backup up your files in another server using encripted SSH

Date: 2007-03-10 00:00:00 -0400

If you have two servers, could be a good idea to make cross backups of the important data, so if any of them fails you can always restore from the other.

Here we will use rsync and ssh to make this possible, rsync is used to sync files between folders on the same machine or between machines, ssh will open an encrypted tunnel so the data could be secure on the transfer.

We will have the option to make this automatic using a cron job

Enable the ssh login with no password

I have written how to do this in the past, so you can go to this link to make it and go back once it is finished, if you do not need to automate this process you don't need this step.

http://www.go2linux.org/ssh-login-using-no-password

Prepare the backing machine

In the machine where the files are going to be copied, enter this commands

cd $HOME mkdir backup

Create the script

This script will run on the backing machine.

#!/bin/sh
#Backup your files with automatic incremental
#Delete the files on destination that have been
#deleted on the source
rsync -e 'ssh -ax' -avz --delete --delete-excluded backed.server:/source/directory $HOME/backup/

Make this script to run in a CronJob as your user (not root, unless you want that) if you do not want this automatic, run by hand each time you want to back up your files.

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.