Taking Snapshots
Note
This feature is experimental.
A disk snapshot is a shallow or full copy of a persistent disk at the time of the snapshot creation. Disk snapshotting is implemented with the help of CPIs which use the IaaS snapshot functionality to efficiently make copies of disks.
Take a disk snapshot of a persistent disk before deploying major updates or for other important events. If the changes corrupt persistent disk, promote a disk snapshot to be a persistent disk and attach it to the VM to restore data prior to your changes.
Note
Currently, BOSH does not provide a CLI command to recover from a snapshot, so you must use the recovery features of your IaaS with the snapshot Content IDs (CIDs) to recover the snapshots.
Note
While snapshots allow you to recover disk to a prior state, snapshots are not backups. Taking a snapshot does not necessarily create a complete copy of the original disk. If the original disk is deleted, your IaaS may invalidate any snapshot files.
Enabling Snapshots¶
Since the IaaS might or might not provide snapshotting functionality, disk snapshots are disabled by default. If your IaaS supports snapshots, you must first enable snapshots in your IaaS and then in the Director.
To enable disk snapshots in the Director:
-
Add an
enable_snapshots
key with it's value set totrue
to thedirector
block of your Director deployment manifest.properties: director: enable_snapshots: true
-
Run
bosh create-env manifest.yml
to update your Director deployment (seecreate-env
command for details).
Manual Snapshots¶
Once you enable snapshots in your deployment, you can use following CLI commands to take snapshots on demand.
Note
When you manually take a snapshot, the Director does not pause any processes or flush buffered data to disk. Depending on your IaaS, a snapshot taken manually might not fully capture all the data on your VM at the point you take the snapshot.
bosh snapshots
Displays the job, Content ID (CID), and created date of all snapshots. Run bosh snapshots
to display a list of CIDs if you need to find specific snapshots to recover.
bosh take snapshot [JOB] [INDEX]
Takes a snapshot of the job VM that you specify. If you do not specify a JOB
, takes a snapshot of every VM in the current deployment.
bosh delete snapshot SNAPSHOT-CID
Deletes the snapshot that SNAPSHOT-CID specifies.
bosh delete snapshots
Deletes all snapshots.
Job Update Snapshots¶
Once you enable snapshots in the Director, the Director automatically takes a snapshot of the persistent disk whenever an event triggers a deployment job update. Before taking the snapshot, the Director waits for release job processes to stop (and/or drain).
Scheduled Snapshots¶
The Director can take snapshot of persistent disks at regular intervals for all VMs in all deployments and/or the VM the Director is running on.
Note
When the Director starts a scheduled snapshot, it does not pause any processes or flush buffered data to disk. Depending on your IaaS, a scheduled snapshot might not fully capture all the data on your VM at the point you take the snapshot.
To schedule snapshots for all VMs in all deployments:
-
Add a
snapshot_schedule
key to thedirector
block of your Director deployment manifest. -
Add a cron-formatted schedule as a value for the
snapshot_schedule
key.properties: director: enable_snapshots: true snapshot_schedule: 0 0 7 * * * UTC
-
Run
bosh create-env manifest.yml
to update your Director deployment (seecreate-env
command for details).
To schedule snapshots for the Director VM:
-
Add a
self_snapshot_schedule
key to thedirector
block of your Director deployment manifest. -
Add a cron-formatted schedule as a value for the
self_snapshot_schedule
key.properties: director: enable_snapshots: true self_snapshot_schedule: 0 0 6 * * * UTC
-
Run
bosh create-env manifest.yml
to update your Director deployment (seecreate-env
command for details).