# Backing Up Between Servers: Techniques



## APseudoUtopia (Dec 10, 2009)

Hey,

I have two servers. They each have backup scrips run daily via a cronjob. I'd like to have each server store the others backup (Eg, ServerA stores ServerB's backup, and ServerB stores ServerA's backup). I'm not sure on how to get started, as I've never used rsync or even ran any type of automated file-transfer.

I was considering doing something such as the following: creating a new unprivileged user account with no password, only accessible via a public key. The current backup files will be stored in that users homedir.Use a cronjob to schedule rsync to run every day after the backup script on each server. The cronjob will sync the backup folder on ServerA with a folder on ServerB, and vise-versa.

I've never used rsync before, so I'll have to read up on how exactly that works. However, are there any common practices to "sharing" backups like this? Is SCP or SFTP preferred over rsync?


----------



## SirDice (Dec 10, 2009)

I think rsync is more usable if you want the same directory/files on multiple servers. I would use backup or tar over an ssh connection.


----------



## phoenix (Dec 10, 2009)

Rsync would work well in this situation.

On ServerA, create a user "backups1".  Configure the backup script to store the backups in this user's home directory.  Create another user "backups2".

On ServerB, create a user "backups2".  Configure the backup script to store the backups in this user's home directory.  Create another user "backups1".

Then, use rsync on ServerA that connects to ServerB as user "backups1" and rsync's that user's home directory.

And, finally, use rsync on ServerB that connects to ServerA as user "backups2" and rsync's that user's home directory.

Afterwards, /home/backups1 on each server will have the backups from ServerA.  And /home/backups2 on each server will have the backups from ServerB.


----------



## Ruler2112 (Dec 10, 2009)

It's not exactly standard, but would be very quick if the files can be fetched.  I created a perl script to fetch a file from a remote machine and keep n backup copies of said file.  You could install it on each machine to suck down a gzipped tar backup archive from the other and thereby have not only one backup, but also however many older ones as well.  This script can be found in the emerging threats thread.


----------



## jalla (Dec 11, 2009)

That's two hosts on your local network?
If so, you could just do it "The Simple Way(TM)" and run your backups directly over nfs to the other host.

(Sometimes I wonder when nfs went out of fashion)


----------



## krkbryant08 (May 5, 2010)

can i have a copy of your backup scripts ???


----------

