2

Let's say I need a long-term backup for a webserver in Google Cloud Platform.

I need to have a possibility to access to the state or restore the state of the machine up to 1 year ago. (Weekly snapshots will be ok.)

Are snapshots a proper solution for such long-term backups?

  1. Can I have snapshots which are 1 year old?
  2. Can I have 54 snapshots for one disk?
  3. Can I switch/restore to older snapshot without loosing more frequent ones?
  4. Can I switch back to current snapshot?
  5. Will 54 snapshots reduce read/write efficiency?
  6. Can I loose all snapshots in any silly way? Like deleting VM or restoring VM in wrong way?
  7. I know I can create new instance and select snapshot as a boot disk? Will snapshot be converted to a new disk or new instance will be depended of snapshot?

If snapshots are not a correct way for long-term backups, what is a correct way?

huhu78
  • 151
  • 1
  • 1
  • 6
  • Provided that you create snapshots from **stopped** Linux VMs, they are fine. Snapshots taken from running machines are only **crash consistent** which is the same thing as yanking the power cord on a running computer. Windows systems provide VSS which does support online snapshots. – John Hanley Sep 28 '21 at 17:55
  • @JohnHanley KVM on Linux (which is what Google VMs are built on) supports VM filesystem consistency with fsfreeze/fsthaw, but the program taking the snapshots must send these commands to the VMM. I don't know offhand if Google does. But it should be easy to find out. The VM can run custom scripts before/after each of these two commands. For example, one exists to tell MySQL to stop accepting queries and go into a consistent state when freezing (and the reverse when thawing). One could write such a script that creates a file before the snapshot. You can check later to see if that file exists. – Michael Hampton Sep 28 '21 at 21:59
  • @MichaelHampton - Google snapshots are crash-consistent. They are not application-consistent without user setup. Users need to set up pre and post snapshot scripts themselves. https://cloud.google.com/compute/docs/disks/snapshot-best-practices#creating_application_consistent_snapshots https://cloud.google.com/compute/docs/disks/creating-linux-application-consistent-pd-snapshots – John Hanley Sep 28 '21 at 22:14
  • @JohnHanley Ah, so Google does support fsfreeze/fsthaw. Excellent news! – Michael Hampton Sep 28 '21 at 22:54

2 Answers2

1

Here are inline responses to your queries -

  1. Yes and even older, you can define how long you want to keep your snapshots in the snapshot retention policy.
  2. Yes. The only constraint here is that you can snapshot your disks at most once every 10 minutes, if you require more frequency than that then you can go with cloning your disk, which features a rate of 1 disk clone every 30 seconds.
  3. Yes, you can see the list of snapshots by using command ‘gcloud compute snapshots list’, you can choose any without losing others.
  4. You can create a new instance with the current snapshot.
  5. It does in VMware but never heard of such issues in GCP.
  6. Deleting/restoring VMs won’t delete snapshots. The mechanisms are very foolproof and have several failsafes; one, for example, If you attempt to create a snapshot from a zonal persistent disk and the snapshotting process fails, you won't be able to delete the original zonal persistent disk until you have cleaned up the failed snapshot. This failsafe helps to prevent the accidental deletion of source data in the event of an unsuccessful backup.
  7. When you create an instance from a snapshot, it still creates a disk.

Check out this doc and this video for additional information.

Anant Swaraj
  • 169
  • 4
0

Yes, according to https://cloud.google.com/compute/docs/disks/data-protection the use case for snapshots is »Long term data backup.«

karlsebal
  • 273
  • 2
  • 14