Cronjob to Create Disk Image of Ubuntu Server 12.04 on External USB Hard Drive

cronhard driveubuntu-12.04

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.

Best Answer

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.)