Creating Instance Snapshots in OpenStack
Creating snapshots of your OpenStack instances provides a reliable way to capture the current state of a virtual machine for backup, recovery, or cloning purposes. A snapshot preserves the instance's disk state at a specific point in time, allowing you to restore or replicate that configuration later.
What is an Instance Snapshot?
An instance snapshot in OpenStack is a point-in-time image of a running or stopped instance. When you create a snapshot, OpenStack captures the root disk contents and saves it as a new image in the Glance image service. This snapshot can then be used to launch new instances with identical configurations or to restore an instance to a previous state.
Key characteristics of instance snapshots:
- Captures the root disk contents of an instance
- Stored as an image in the Glance image service
- Can be used to launch new instances or restore existing ones
- Includes the operating system, installed applications, and configuration files
- Does not include ephemeral storage or attached volumes by default
When to Use Instance Snapshots
Instance snapshots are valuable in several scenarios:
Before major changes: Create a snapshot before performing system updates, configuration changes, or software installations. If something goes wrong, you can restore the instance to its previous state.
Backup and disaster recovery: Regular snapshots provide recovery points if an instance becomes corrupted or experiences data loss.
Scaling identical workloads: Use a configured and tested instance as a template by creating a snapshot, then launch multiple instances from that snapshot.
Development and testing: Snapshot a production instance to create identical staging or testing environments without affecting live systems.
Migration preparation: Create snapshots before migrating instances between regions or availability zones.
Creating a Snapshot Using Horizon
The OpenStack Horizon dashboard provides a straightforward interface for creating instance snapshots.
Step 1: Access the Instances page
Log in to the Horizon dashboard and navigate to Project > Compute > Instances. Locate the instance you want to snapshot in the instances list.
Step 2: Initiate the snapshot
Click the dropdown arrow next to the Create Snapshot button in the instance's action column. Alternatively, click the instance name to view its details, then select Create Snapshot from the actions menu.
Step 3: Configure the snapshot
In the Create Snapshot dialog:
- Snapshot Name: Enter a descriptive name that identifies the snapshot's purpose and date. For example,
web-server-01-pre-upgrade-2026-01-29. - Description (optional): Add notes about the snapshot's purpose, configuration details, or any relevant context.
Step 4: Create the snapshot
Click Create Snapshot to begin the process. OpenStack will create the snapshot in the background. The time required depends on the instance's root disk size.
Step 5: Monitor snapshot progress
Navigate to Project > Compute > Images to view your snapshots. The snapshot will initially show a status of "Queued" or "Saving," then transition to "Active" when complete.
Creating a Snapshot Using the CLI
The OpenStack command-line interface provides more control and is useful for automation or scripting.
Prerequisites:
- OpenStack CLI client installed and configured
- Valid credentials and authentication
Basic snapshot command:
1openstack server image create --name "web-server-snapshot-2026-01-29" SERVER_ID_OR_NAME
Replace SERVER_ID_OR_NAME with your instance's ID or name.
Create a snapshot with a description:
1openstack server image create \2 --name "database-server-snapshot" \3 --description "Pre-migration backup of production database server" \4 db-prod-01
Wait for completion:
The CLI command returns immediately, but the snapshot creation continues in the background. Monitor the status with:
1openstack image list --name "web-server-snapshot-2026-01-29"
When the status shows "active," the snapshot is ready to use.
Verify snapshot details:
1openstack image show SNAPSHOT_ID
This displays comprehensive information including size, creation date, and properties.
Snapshot Best Practices
Following these practices ensures reliable snapshots and efficient management:
Shut down applications gracefully: Before creating a snapshot, stop application services or put the instance in maintenance mode. This ensures data consistency and prevents corruption in database files or cached data.
Use consistent naming conventions: Include the instance name, date, and purpose in snapshot names. For example: app-server-03-pre-update-2026-01-29 or web-frontend-weekly-backup-20260129.
Add descriptive metadata: Use the description field to document the snapshot's purpose, any special configurations, or dependencies. This context becomes invaluable when managing multiple snapshots over time.
Schedule regular snapshots: Establish a snapshot schedule aligned with your backup requirements. Daily snapshots for critical systems, weekly for less critical workloads.
Verify snapshot integrity: Periodically test snapshots by launching instances from them and verifying that applications start correctly and data is intact.
Implement retention policies: Define how long to keep snapshots based on their purpose. Development snapshots might be kept for days, while compliance-related snapshots may need retention for years.
Consider volume snapshots for data: Instance snapshots only capture the root disk. For instances with attached Cinder volumes containing important data, create separate volume snapshots to ensure complete backup coverage.
Managing and Organizing Snapshots
Effective snapshot management prevents storage bloat and ensures you can quickly find the snapshots you need.
Tagging and metadata:
Add tags or custom metadata to snapshots for easier filtering and organization:
1openstack image set \2 --property backup_type=weekly \3 --property environment=production \4 SNAPSHOT_ID
Listing snapshots:
Filter snapshots by properties:
1openstack image list --property image_type=snapshot
Deleting old snapshots:
Remove snapshots you no longer need to free storage space:
1openstack image delete SNAPSHOT_ID
Before deleting, verify that the snapshot is no longer required for recovery or compliance purposes.
Snapshot storage considerations:
Snapshots consume storage in the Glance image service. Large instances with substantial root disks create correspondingly large snapshots. Monitor your project's storage quota and snapshot count to avoid hitting limits.
Launching Instances from Snapshots
Once you have a snapshot, you can launch new instances or restore an existing one.
Launch a new instance from a snapshot using Horizon:
Navigate to Project > Compute > Images, locate your snapshot, and click Launch Instance in the actions column. Configure the new instance's flavor, network, and other settings as needed.
Launch using the CLI:
1openstack server create \2 --image SNAPSHOT_ID \3 --flavor m1.medium \4 --network private-network \5 --key-name my-keypair \6 restored-instance-name
Restore an existing instance:
To restore an instance to a snapshot state, you typically need to rebuild the instance:
1openstack server rebuild --image SNAPSHOT_ID INSTANCE_ID
Be aware that rebuilding replaces the instance's root disk with the snapshot contents. Any changes made after the snapshot was created will be lost.
Snapshot Limitations and Considerations
Understanding snapshot limitations helps you use them effectively:
Root disk only: Instance snapshots capture only the root disk. Ephemeral storage and attached Cinder volumes are not included. You must create separate volume snapshots for complete coverage.
Downtime considerations: While you can snapshot running instances, the safest approach is to shut down the instance first. For production systems where downtime is unacceptable, use application-aware backup tools or implement volume-based snapshots with filesystem quiescing.
Size and time: Larger root disks take longer to snapshot and consume more storage. A 100GB root disk creates a 100GB snapshot image.
No incremental snapshots: Each instance snapshot is a full copy of the root disk. OpenStack does not support incremental instance snapshots, though volume snapshots may use copy-on-write mechanisms depending on the storage backend.
Performance impact: Creating snapshots of running instances can cause brief I/O pauses or performance degradation during the snapshot operation.
Snapshot vs. Volume Backup
OpenStack provides multiple backup mechanisms. Understanding when to use each ensures comprehensive data protection:
Instance snapshots are best for:
- Capturing the entire system state including OS and configurations
- Creating templates for deploying identical instances
- Quick rollback of system changes
Volume snapshots and backups are better for:
- Backing up persistent data on Cinder volumes
- Incremental backup strategies (with appropriate backends)
- Long-term data retention independent of instance lifecycle
For production systems, use both: instance snapshots for system recovery and volume backups for data protection.
Automating Snapshot Creation
Automation ensures consistent backup coverage without manual intervention.
Using cron and OpenStack CLI:
Create a shell script that generates snapshots:
1#!/bin/bash2DATE=$(date +%Y%m%d)3INSTANCE_ID="your-instance-id"4SNAPSHOT_NAME="instance-backup-${DATE}"56openstack server image create \7 --name "${SNAPSHOT_NAME}" \8 --description "Automated daily backup" \9 "${INSTANCE_ID}"
Schedule the script with cron:
10 2 * * * /path/to/snapshot-script.sh
Retention and cleanup:
Extend your automation to delete old snapshots:
1# Delete snapshots older than 7 days2CUTOFF_DATE=$(date -d '7 days ago' +%Y%m%d)34openstack image list --property image_type=snapshot -f value -c ID -c Name | \5while read -r id name; do6 if [[ $name =~ instance-backup-([0-9]{8}) ]]; then7 snapshot_date="${BASH_REMATCH[1]}"8 if [ "$snapshot_date" -lt "$CUTOFF_DATE" ]; then9 openstack image delete "$id"10 fi11 fi12done
Troubleshooting Common Snapshot Issues
Snapshot creation fails or hangs:
Verify that you have sufficient storage quota in your project. Check the Glance service status and logs if snapshots consistently fail. Ensure the instance is not performing intensive I/O operations during snapshot creation.
Snapshot takes excessive time:
Large root disks naturally require more time. If snapshots seem abnormally slow, check the underlying storage system's performance and capacity.
Instance fails to launch from snapshot:
Verify the snapshot status is "active" before attempting to launch. Check that the snapshot image is compatible with the selected flavor and that required networks and security groups are properly configured.
Snapshots consume unexpected storage:
Remember that each snapshot is a full copy of the root disk. Implement retention policies and regularly clean up old snapshots to manage storage consumption.
Summary
Instance snapshots are a fundamental tool for backup, recovery, and instance replication in OpenStack. By creating regular snapshots before changes, implementing consistent naming conventions, and establishing retention policies, you ensure reliable recovery options while managing storage efficiently. Combine instance snapshots with volume backups for comprehensive data protection across your cloud infrastructure.
For production environments, automate snapshot creation and cleanup processes to maintain consistent backup coverage without manual intervention. Always test your snapshots periodically by launching instances and verifying application functionality to ensure your backup strategy works when you need it most.
