Skip to content

How to schedule volume snapshots and restore data

How-to · Updated Sep 2026

Coming from another cloud?

▸AWS·EBS Snapshots

EBS Snapshotshigh

  • Per-EBS volume, incremental in S3; not full instance image.
  • Via EC2 CreateSnapshot API, not Nova/Cinder.
  • Async pending state, volume usable during snapshot.
  • Billed per GB-month stored.
AWS docs ↗
▸DigitalOcean·Volume Snapshots

Volume Snapshotshigh

  • Proprietary API /v2/volumes/{volume_id}/snapshots instead of OpenStack /v3/{project_id}/snapshots.
  • Explicitly crash-consistent only, no automatic filesystem consistency (requires manual power-off/sync); OpenStack snapshots can use quiescing drivers for apps like databases.
  • Snapshots billed separately based on block-level used size (may exceed filesystem due to trim); OpenStack typically similar. See the DigitalOcean pricing page for current rates.
  • Can create new volumes only in same region as snapshot; OpenStack snapshots more flexible for cross-region with upload/download.
DigitalOcean docs ↗

How to schedule volume snapshots and restore data

Schedule recurring Cinder volume snapshots with cron on a control instance or a CI workflow. Set a retention period, remove expired snapshots, and test restores on a recovery volume.

Prerequisites

Windows: CLI examples use bash. Set up a Linux CLI environment on Windows before proceeding.

Create a snapshot manually#

See How to create a volume snapshot for the Console, CLI, and API paths.

Schedule with cron on an instance#

On a tooling VM in the same project, open the cron configuration:

bash
crontab -e

Add this cron entry to create a snapshot at 02:00 UTC each night:

0 2 * * * openstack volume snapshot create --volume MY_VOLUME --force --description "nightly-$(date +\%F)" nightly-$(date +\%F)

Source OpenStack credentials from /etc/openstack/env, and restrict the file to its owner with chmod 600. Use an application credential for the job.

Retention loop#

Delete snapshots older than seven days:

bash
openstack volume snapshot list -f value -c ID -c Name | while read -r id name; do
  case "$name" in nightly-*)
    # parse date from name and delete when older than retention window
    openstack volume snapshot delete "$id"
  ;; esac
done

Run the retention script weekly from the same cron user.

Schedule with GitHub Actions#

YAML
on:
  schedule:
    - cron: '0 2 * * *'
jobs:
  volume-snapshot:
    runs-on: ubuntu-latest
    steps:
      - run: pip install python-openstackclient
      - run: openstack volume snapshot create --volume "$VOLUME_ID" --force "ci-$(date +%F)"
        env:
          OS_AUTH_URL: ${{ secrets.OS_AUTH_URL }}
          OS_AUTH_TYPE: v3applicationcredential
          OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
          OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
          OS_REGION_NAME: ${{ secrets.OS_REGION_NAME }}
          OS_PROJECT_ID: ${{ secrets.OS_PROJECT_ID }}

See Deploy an application from CI for secret naming patterns.

Restore from a snapshot#

  1. Create a new volume from the snapshot (create volume with --snapshot source).
  2. Attach the volume to a recovery instance.
  3. Mount the filesystem and verify data, or replace the production volume during a maintenance window.
  4. Run an application-level restore drill (database consistency check, file checksum).

See also#

Usage Guidelines

The sample code, software libraries, command line tools, proofs of concept, templates, and other related technology on this page (including any of the foregoing that is provided by Quake AI personnel) is provided to you as Quake AI Content under the Quake AI Customer Agreement, or the relevant written agreement between you and Quake AI (whichever applies). Do not use this Quake AI Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the Quake AI Content (such as sample code) as appropriate for production grade use based on your specific quality control practices and standards. Deploying Quake AI Content may incur Quake AI charges for creating or using Quake AI chargeable resources, such as running Compute instances or storing data in Object Storage. Your use is also subject to the Acceptable Use Policy.

For the full policy, see Usage Guidelines.

Last validated: 01.09.2026

Quick answers

Was this page helpful?