Skip to content

Backups

Amber Yust edited this page Mar 18, 2017 · 4 revisions

Implemented in #108, the pepperoni instance is snapshotted once a day (currently at 0930 UTC to fall in a low-activity period). This is done via a cron job (root crontab) that invokes /root/snapshots.sh, a script which:

  1. Creates a new daily snapshot for each of the two disks (pepperoni and pepperoni-data).
  2. Cleans up any snapshots older than 30 days.
    • snapshots.sh has a failsafe: it will refuse to delete snapshots if, by its logic, it thinks it should delete all of them.

The set of existing snapshots can be found on the Google Cloud Console's Snapshots page.

Restoring from a snapshot

Due to how GCE's "attached disks" work, restoration from a snapshot is relatively straightforward - you create a new disk based on a snapshot, and then you attach that disk instead of the old one.

  1. gcloud compute disks create example-disk --source-snapshot=example-snapshot
  2. gcloud compute instances attach-disk example-instance --disk=example-disk

Note that you'll likely want to have the pepperoni instance stopped while you're doing this, as you'll be detaching one or more disks to replace them with restored versions. Attached disks are mounted into the file system based on the name of the disk, so as long as your newly attached disk has the same name, it should be mounted properly (or you can manually mount a disk with a different name in the same location) - here's an example /etc/fstab line:

/dev/disk/by-id/google-pepperoni-data   /mnt/data       ext4    rw,relatime,data=ordered        0 0

If the disk that you need to restore is a boot disk rather than just an attached data disk, you may need to take a different path - essentially, creating a new VM based off of a snapshot of the boot disk image. You can do this pretty easily by going to the Cloud Console, clicking through to an individual snapshot's page, and using the "Create Instance" button.

Clone this wiki locally