HowTo: Checkpoint Backup a KVM VPS on SolusVM
I have a barebones testing VPS, which, as they are insanely cheap, I think everyone should have one. True, these aren't really usable by retail website owners, but if you're in IT and take QA seriously they're wonderful.
The one big issue with these are having to rebuild them from scratch when you want to try a different set of software packages that will emulate a clean production build and configuration. The solution was relatively easy, but the journey was a pita.
SolusVM's Central Backup seemed to be the ideal solution, but, it's not:
Central Backup is a feature they no longer support (until 1.16.0 when they re-code it), so it's actually impossible to install it at this point. Basically, if you have an older install you can still use it, but new installs don't work. Unfortunately it hasn't been supported for over a year now...
-- Linux System Administrator, 5/16/2014
The server I was using for testing was originally an OpenVZ, but OpenVZ doesn't have the capability to mount a rescue DVD, so with OpenVZ you are stuck with file level tools. Linux file level tools don't have the capability to restore the full system to a specific checkpoint, as the files you're trying to create a snapshot of are in use, and there is no assurance a restore will be workable.
So, after deleting the OpenVZ and rebuilding on a KVM, I could finally create the snapshots system images I wanted. Typical IT though, spend hours of time upfront to save 10x hours of time later...
Now to the fun part, after building your new KVM server to a point you want to be able to restore it to, these are the steps to create and restore a checkpoint system image:
Creating and Restoring a Checkpoint System Image
- Login to your SolusVM Control Panel.
- Click the "Shutdown" button.
- On the "Settings" tab, change the "Boot Order" to "CDROM Only."
- On the "CDROM" tab, select either the "x64" or "x86" version of "CentOS 6.x " as appropriate for your system, and then click "Mount."
- Click the "Boot" button.
- Click the "VNC" button.
My VNC Viewer [QEMU (kvm616)] is annoying as it doesn't do copy and paste.
When the VNC Viewer comes up:
- Press "Esc" (Before the 60 second timer auto-boots the installation!)
There is a good chance the VNC Viewer screen will now be unreadable or just blank. Just start typing:
- # linux rescue
Then use the "Tab" and "Enter" keys to navigate though the screens:
- "Choose a Language," "Keyboard Type," etc.
At "Enable network interface" screen, most likely your host will have DHCP setup, try that first for networking. After NetworkManager starts, you will get to the last screen, "Rescue," where it asks to mount disk(s), select:
- Skip >> Start shell
While most likely under KVM your partition will be /dev/vda, you can use:
- # fdisk -l
to verify or identify your partition information. And finally!
Backup & Restore Raw data
- # dd if=/dev/vda | ssh USERNAME@IP "dd of=/SAVEDIR/chkptNN.iso"
- # ssh USERNAME@IP "dd if=/SAVEDIR/chkptNN.iso" | dd of=/dev/sda
Backup & Restore Compressed data
- # dd if=/dev/vda | gzip | ssh USERNAME@IP "dd of=/SAVEDIR/chkptNN.iso"
- # ssh USERNAME@IP "dd if=/SAVEDIR/chkptNN.iso" | gzip -d | dd of=/dev/sda
When you're finished making backups or restoring, don't forget to:
- Change the "Boot Order" on the "Settings" tab back to "Hard Disk" and "Reboot."
That's it, enjoy your time savings,
# # #
Statistics using a 50 GB drive
Raw Backup: File size, 50G - Time, 01:06:12
Compressed Backup: File size, 2.1G - Time, 00:31:46
Compressed Backup: File size, 50G - Time, (didn't perform)
Compressed Restore: File size, 2.1G - Time, (between 50 and 100 minutes.)
1) Using SSHFS (SSH Filesystem)
SSHFS is a very nice program that would simplify the backup/restore process, and you will find web references to using it for this purpose, but:
sshfs is not included in any distribution out of the box, its not a commonly used package, you will need to use your Yum or Apt-get to install it.
-- Linux System Administrator, 5/17/2014
Unfortunately installing something in a rescue environment is not doable without extra effort.
2) Want a smaller Compressed image?
For space considerations, if you are using the gzip command version, and your filesize is not significantly reduced, it is probably best to write zeros to the entire disk before anything else. To do so, boot into rescue mode and issue the command:
Obvious Warning: Doing this will delete all content on your disk!
# dd if=/dev/zero of=/dev/vda