I had a xen VPS running Debian 8 that had to come offline so I backed it up using rsync like this.

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder

I then put that backup folder into a tar.gz and moved it off to my local machine.

I now have a KVM VPS online also running Debian 8 that I need to restore to. How do I restore that backup? Is there anything additional I need to do to make sure it boots? Can it be done over SSH/SCP?

  • Did you try it? Just give it a try - if it doesn't work out, start from scratch again - it's simple enough to do with a VPS. :) – EEAA Jul 2 '16 at 15:59
  • That's true. I was just looking to understand the correct way before getting into it. – Mitch Jul 2 '16 at 17:02

You missed one possibly vital argument to rsync: --hard-links. It depends on the distribution, and I guess it's different now than it is in the past, but system directories and/or files (more so than user files) can easily be hard links to others. For example, in the somewhat recent past on Archlinux, /usr/X11R6/bin was a hard-link to /usr/bin. At present, I couldn't give you concrete examples of how it would be today. You could look into it.

You may also have lost vital information by putting it into a tar.gz. Does it store ACLs? Would it have stored hard links?

You also missed --sparse, but that's merely an inconvenience.

To restore it, I'd boot a live CD, or some kind of rescue environment your VPS provider gives you. You can then just untar the data into the root partition, chroot into it (with bind-mounting /proc, /dev and /sys) and running something like grub-install /dev/sda

These options can vary depending on your setup.

Edit: since you may have access to your original VPS, you can do something like this:

pv /dev/vda | gzip --fast | ssh user@somehost.example.com "cat - > imagefile.gz"

And then on the rescue environment on the new host the reverse:

pv imagefile.gz | ssh user@somehost.example.com "gunzip - > /dev/sda"
  • Thanks for your response. You made good points, and your right my backup was not done properly. I'll see if that VPS is still around to reperform the backup and go from there. – Mitch Jul 2 '16 at 17:00
  • @Mitch If the entire machine is available, can you boot into a rescue environment and just use dd to do a block level backup? I could give you some examples if you want. – Halfgaar Jul 2 '16 at 17:02
  • The machine is not available unfortunately. For now we just went the route of doing a fresh installation and pulling over the content we needed from the backup that I had. Thank you for your assistance though, and I will be more careful to backup correctly in the future. – Mitch Jul 9 '16 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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