From PrgmrWiki
Revision as of 19:04, 28 June 2017 by Adp (talk | contribs) (remove obsolete x-refs now that pages are merged.)

What are some ways to backup the vps? How should a backup be done while in the rescue image or while the vps is running?

A full backup is only possible while in the rescue image, and there is often not enough tmp space to use as a destination, so it needs to be copied over the network directly to the destination. One way is to setup a special account with its own password or ssh keys on the backup destination server, then pipe tar or gzip through ssh. This works with a filesystem image directly from or to a partition, or with tar and a mounted filesystem. (Some more details: Backing_up_disk_image_via_SSH)

Editing Backing up disk image via SSH

backing up new system to another server ...

my current procedure to grab compressed disk image:

  • boot to Centos rescue image (described on the Password Reset page)
  • mkdir /tmp/xvda1
  • mount /dev/xvda1 /tmp/xvda1
  • dd if=/dev/zero of=/tmp/xvda1/big_blank_file
  • rm /tmp/xvda1/big_blank_file
  • umount /tmp/xvda1
  • bzip2 < /dev/xvda1 | ssh me@my.other.server.tld "cat > xvda1_backup.bz2"

(The "big_blank_file" finagling for compressability may be not particularly necessary on a fresh image ...) With the zero-pad prep, a fresh Debian Lenny image (about 500 MB installed on a 12 GB disk) compresses down to less than 185 MB. After installing Apache2 and some user data, the disk image compressed from about 750 MB down to about 250 MB - without repeating the zero-pad prep.

Alternatively, you might do something like this:

  • boot to Centos rescue image
  • e2fsck -f /dev/xvda1
  • resize2fs -M /dev/xvda1
  • bzip2 < /dev/xvda1 | ssh me@my.other.server.tld "cat > xvda1_backup.bz2"

Which has the added benefit of downsizing the partition to its smallest possible size (i.e., completely full), so if you are restoring to a smaller device, you will not fill up the device with unused space.

Also, see Restore