I have a 1TB external hard drive and would like to take a snapshot of the entire server periodically (maybe once a week). For cronjob part, I plan on pointing to a bash script in:
$ sudo crontab -e
but have no idea what tool I could use to make a disk image of the server while it's running. Would it have to be down while creating the image? I was looking at Clonezilla but it looks like I have to first set up a DRBL server which seems like something I don't want.
I also don't know how long it might take to run a backup or if there's any way to only do incremental changes. I plan on storing ~500GB of data there.
Do I need to format the external hard drive any particular way? Does anyone know of good tutorials/starting points?
Thanks in advance.
You can use rsync to make a copy of the entire system. It won't be an "image" per se, but it will contain a copy of all files on the system. For example, you could do:
rsync -aHAXxv / /mnt/backup/
This would copy everything in the root filesystem to /mnt/backup. (Note, it only copies one filesystem due to -x, so if you have multiple filesystems, you'd need to do multiple commands, or omit -x and use --exclude to exclude the backup path.)
Try fsarchiver http://www.fsarchiver.org/QuickStart It allows you to create live backup from partition, and multithreaded image compression. Unfortunately incremental backups are somewhat difficult with that. Maybe using rsync on dd image of partition? Consider making compressed partition image, and rsync/bacula incremental backup of some folders maybe.
It may be better to think about what you're backing up - taking a disk image would necessitate some form of trickery so as not to get it corrupt due to the running system - two ways I can think of:
The other options are to backup your created data and configs, and leave the "OS bits" to be recreated by a new install - maybe you could even script the install for super-fast DR. It will save you many gigs of backup space too - meaning you can back up more frequently, and hold longer retention.
As mentioned by @yesterday you could use rsync like this:
This would create a backup auf
/
but not of other mounted partitions like/var
So you should do this for every partition you need to backup.But to make sure, that you have a consistent backup, you should use LVM Snapshots if available. For example: