# backup server (hot spare)



## scavern (Sep 1, 2009)

I have two FreeBSD servers, and would like to use the second one as a backup in the event that the other server fails.

The hardware is identical. How can I set everything up so that the backup server always has a copy of the data that is on the primary server ?

I'm thinking rsync - but not really sure if it is the right way to go.


----------



## vivek (Sep 1, 2009)

rsync over ssh is way to go. First, time it will take some time after that it will be just updates. Setup cron jobs to sync server. Also, for mysql setup replication or simply keep mysqldump command dumps.


----------



## SirDice (Sep 1, 2009)

vivek said:
			
		

> Also, for mysql setup replication or simply keep mysqldump command dumps.



It'll be better if you setup master-slave or master-master for mysql.

http://dev.mysql.com/doc/refman/5.0/en/replication.html


----------



## scavern (Sep 2, 2009)

You will have to forgive my noobish questions... 

Can I use rsync to copy all the partitions from a live system ? 

Also, what will happen if say for example the primary server goes down in the middle of a rsync process ?


----------



## dennylin93 (Sep 2, 2009)

Rsync simply copies the files, so all the files on the system can be copied with enough privileges. However, dump may be preferable for entire partitions.

If the server goes down in the middle of a rsync process, I think it would stop immediately and exit with an error, but I'm not sure (never experienced this before).


----------



## scavern (Sep 2, 2009)

Thanks. My worst fear is that something happens in the middle of copying, and then I am left with two unusable servers. Although I suppose a way around this would be to copy the files to a temporary location first. Does anyone have any links to some decent rsync tutorials ?


----------



## dennylin93 (Sep 2, 2009)

Usually, the situation doesn't get that bad. With UFS, data is rarely lost. Even if your master goes down, most of the files should still be intact (perhaps a few runs of fsck might be needed). ZFS has built-in checksumming, but since I don't use it for production, I can't say if it's good or not (some of the other users are saying that it's fabulous though).

A safer option might be to make a snapshot and rsync that instead. This is feasible with both ZFS and UFS.

There's a tutorial about backups using UFS and ZFS in the Howtos & FAQs section: Remote backups server using FreeBSD, ZFS, and Rsync. Another tutorial about rsync and SSH.


----------



## DutchDaemon (Sep 2, 2009)

sysutils/rsnapshot


----------



## scavern (Sep 2, 2009)

Great - thanks everyone. I'll do some reading up on rsync + rsnapshot and then test it out.


----------



## mix_room (Sep 3, 2009)

I'm going to go ahead and say that rsync/rsnapshot may not be the best solution. Depends on what you REALLY want/need. 

Do you have the time or ability to manually switch over, or must this be handled automatically. If all you need is a backup which can be switched over within a few minutes/hours then by all means go with rsnaphost/rsync. 

However: if you require a hot-standby then perhaps something such as sysutils/heartbeat might be something for you: http://linux-ha.org/


----------



## scavern (Sep 3, 2009)

The ideal solution would be the hot-standby - but the question then is how do I ensure that the backup server has a copy of all the data on the primary server at any time ?

I can afford a few minutes -not hours downtime.


----------



## DutchDaemon (Sep 3, 2009)

Can you afford a SAN/NAS solution, i.e. a shared/common back-end?


----------

