What's the best way to backup a (virtual) server prior to shutting it down and disposing of it?
Assume only a single filesystem, which in turn means that the backup will have to go onto that filesystem (obviously on completion the file would be copied off before the server was killed!); also assume no access to it except via SSH so no image backups etc.
Objectives: To have access to everything in case it was needed, and ideally to be able to rebuild the server as it was should it be needed again in future.
Mark
On Thu, Oct 16, 2014 at 05:26:52PM +0100, Mark Rogers wrote:
Objectives: To have access to everything in case it was needed, and ideally to be able to rebuild the server as it was should it be needed again in future.
Login to the machine, stop all the services (apart from ssh!) and then use rsync (or similar) over ssh to effectively take an image of it to another place.
Then create a new vm in the new place that is a copy of all of this data, fix the bootloader and boot it up and see if it's working, relax.
Why can't you power it off and take an image? Is it hosted on someone elses cloud where you can't do this?
Adam
On 16 October 2014 17:50, Adam Bower adam@thebowery.co.uk wrote:
Login to the machine, stop all the services (apart from ssh!) and then use rsync (or similar) over ssh to effectively take an image of it to another place.
I'd prefer to create a backup locally rather than transfer the entire contents with rsync; I don't want to rely on having sufficient disk space on the destination for a full uncompressed backup, and I want to keep an eye on bandwidth (not least because the destination is my office over a measly 4Mbps ADSL line shared with other users). Yeah, I know it's a pain when you give someone an answer to their question and they throw a bunch of additional info at you they didn't include first time, so sorry about that (I'd already ruled out rsync in my head before I asked the question).
I assume I can (with the right combination of switches to avoid infinite recursions, /dev etc, and trying to back up the backup file) go with tar cjf /mybackup.tar.bz2 / <insert switches here> which would be closer but I wasn't sure if there was a better way? (If not, advice as to what switches I need would be appreciated.)
Then create a new vm in the new place that is a copy of all of this data, fix the bootloader and boot it up and see if it's working, relax.
To be honest I'm not too concerned about this; I'll almost certainly only ever want to pull specific files from the backup in this case, although knowing I could rebuild the server from it would be a definite plus.
Why can't you power it off and take an image? Is it hosted on someone elses cloud where you can't do this?
Yup, that's exactly it!
Even hosts that do allow this don't always allow me to download the resulting image though, and if they do there's no guarantee that I can use it on another host (or locally in a VM). So I was looking for options that I control rather than anything a host would provide.
On 17 October 2014 09:43, Mark Rogers mark@quarella.co.uk wrote:
I assume I can (with the right combination of switches to avoid infinite recursions, /dev etc, and trying to back up the backup file) go with tar cjf /mybackup.tar.bz2 / <insert switches here> which would be closer but I wasn't sure if there was a better way? (If not, advice as to what switches I need would be appreciated.)
Taking this as a starting point gives me something to Google for, with some good results assuming tar is the right place to start (see below). As always with the Internet, lots of slightly different versions so I'd still appreciate comments/corrections or suggestions for tar alternatives, but otherwise I think I have my answer...
Eg, from http://www.aboutdebian.com/tar-backup.htm:
tar -cvpf /backups/fullbackup.tar --directory=/ \ --exclude=proc --exclude=sys --exclude=dev/pts \ --exclude=backups .
Or from: http://community.spiceworks.com/how_to/show/381-how-to-backup-and-restore-an...:
sudo tar cvpzf backup.tgz --exclude=/proc \ --exclude=/dev --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
Or from https://help.ubuntu.com/community/BackupYourSystem/TAR:
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz \ --one-file-system /
Mark