Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a VPS with Debian 6 (squeeze) and want to back it up on an external drive at home, so that in case of failure I can restore the complete operating system with all software, settings and databases.

The solution I think of is to rsync the server's / directory to the external drive, like rsync --one-file-system --archive "root@server.address:/" "/media/backup". The --one-file-system option will exclude virtual directories like /proc, /sys, /dev and /run.

Most VPS providers don't have the option of booting the server from a virtual CD or modifying its filesystem when it's not running, so backup restoration to a new VPS would have to involve a fresh install of Debian modifying itself.

I think it can be done by rsyncing the external drive to the server's / directory, with a command like rsync --one-file-system --archive --delete "/media/backup" "root@new.server.address:/". --delete is used to delete files on the server that are not in the backup, and --one-file-system not to delete virtual directories (that were excluded when making the backup).

The virtualization platform is OpenVZ, so the kernel is shared and /boot is empty.

Is the described solution reliable? Should I exclude some more directories? If the solution is not reliable, what alternative do you suggest?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Is the described solution reliable?

The only thing you need to be careful of is ensuring critical files are not being written to or otherwise in heavy use when you make the rsync. Other than that, this method will work fine. It's reliable in this sense because Linux has no concept of a registry or global key/value data-store.

One thing you might want to do is disable uid/gid matching (--numeric-ids), otherwise if your destination system has a user with the same user/groups (e.g. nobody or mailman) then rsync will swap the UID, and may/may not swap it back depending on what order you restore the files (e.g. if /etc/passwd is present with the mappings or not).

Should I exclude some more directories?

I don't feel this is necessary. I've used -auvz when making rsyncs and never had an issue with them. You might want to use rsnapshot, it'll give you rsyncs plus rotational backups at little additional cost.

share|improve this answer
    
You may want to take a look at Hot Copy for snapshotting functionality without LVM. It requires loading a kernel module, though. So using it in an OpenVZ environment likely would not be an option unless the provider has loaded it for you. –  the-wabbit Jul 17 '12 at 11:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.