7

Is it possible to direct copy an entire VPS host to my own server?

My current VPS is in the US and the response times from/to Denmark are bugging me a lot. I have previously had my own server, running FreeBSD, before I switched to the VPS. For the sake of a quick'n'easy move, I wondered if I could just make a diskimage of the VPS and then extract it to my server which I have placed at my workplace here in Denmark.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
Phliplip
  • 541
  • 8
  • 22

3 Answers3

4

Presuming some kind of linux/bsd, it's actually possible to copy a 'running' system over to another one. The target is strongly recommended to be booted in something other than the systemdisk (rescue system, or swap partition with mini system installed).

The advantage of this approach is all kinds of settings are identical (permissions, user crontabs, web server library versions, ...). Of course you also copy over all the cruft that has built up as well.

First turn of everything holding important data or not strictly required (database, http server, all kinds of daemons etc).

You can then tar / and copy it over, install the bootloader on the target system.

Then reboot.

Any running daemons may think the system crashed, but it should be no worse than pidfile overrides.

Tips:

  • start the whole operation from a screen or use nohup.
  • Pipe the tarball over ssh: root@source:~# tar czvf - / | ssh root@target "tar -xzv -C targetpartition/ -f -".
  • Preferably umount any data partitions and give them a seperate treatment. Keep in mind the mountpoint (underlying the mounted fs) may have had files.
  • Carefully check hardware configuration, bootloader config, fstab and ethernet config (nothing worse than a successful conversion that's unreachable from the internet because eth0 and eth1 are switched arround)
  • Make sure tar takes over uid/gid/permissions and extended attributes (if any). Requires root on unpacking, hence the ssh root login in my example.
  • It is a lot easier if you have a remote reset and rescue system on the target. If things don't work out at first, you can check the syslog for errors etc.
  • Don't do this under time pressure or substance influence ;-)
Joris
  • 5,969
  • 1
  • 16
  • 13
  • Best answer yet :) Exactly the direction i was thinking about. Do i have to install the OS on the target system? Or should i just run it with a liveCD, think thats what its called when OS runs from directly from disk (not installed on harddrive). – Phliplip Sep 19 '10 at 17:46
  • By copying the source system, you actually 'install' it on the target hardware. However, it can be a help to install it first and then overwrite it, this way you can keep the essential configs made for you by the installer (all required required modules in initrd, network config with correct interfaces and fstab. – Joris Sep 19 '10 at 18:37
1

I've had a VPS with Linode for many years and have, on a couple of occasions, needed to back up my entire disk image. Linode has some documentation on how to copy your disk image to your local machine via ssh. These instructions are written specifically with linode's infrastructure in mind, but it shouldn't be too difficult to adapt to another provider's setup.

EEAA
  • 109,363
  • 18
  • 175
  • 245
0

Generally most providers don't provide for creating images of VPS systems. And you won't be able to do so yourself because you'd need to boot it from something other than the disks you're wanting to image. Some providers do provide full-disk backups though (especially the cloud-hosting ones such as Amazon and Rackspace), so check with your provider.

You should already have a backup solution in place which allows for full loss of the complete server, and you should be experienced in restoring from this - doing practise restores regularly. And if you're not then this would be a great time to start since it will allow you to have a full practise and find out what you've forgotten to backup.

It may also be time to upgrade your OS and/or some of the software running on it, which doing a restore from backup would allow and a disk image wouldn't. A restore from backup would also allow you to do some minor tweaking of certain settings which weren't quite working for you as you restore. But I wouldn't make any major changes unless you're willing to spend the time fixing breakages.

WheresAlice
  • 5,530
  • 2
  • 24
  • 20
  • I have backup solution as part of the VPS controlpanel, both domain wise and a snapsho - Maybe i could download this snapshot and extract it on the new server - hmmm. Also i have root access to the VPS server and physical access to the new server - which is my own. – Phliplip Sep 19 '10 at 15:17