Vagrant Snapshots Overview
Snapshots save the exact state of your OEL 8 VM at a specific point in time. You can restore to any snapshot instantly. For database work, snapshots are invaluable — take a snapshot before a risky migration, test it, and roll back in seconds if it goes wrong.
Two Snapshot Methods
| Method | Command | How it works |
|---|---|---|
| Named snapshots | vagrant snapshot save NAME | Save with a specific name — can have many |
| Push/Pop (stack) | vagrant snapshot push/pop | Stack-based — unnamed, LIFO order |
Named Snapshots
BASH — Named Snapshots
# Take a named snapshot
vagrant snapshot save clean-oel8
# Take snapshot of specific machine
vagrant snapshot save master mysql-installed
# List all snapshots
vagrant snapshot list
# List snapshots for specific machine
vagrant snapshot list master
# Restore a snapshot (VM state goes back to that point)
vagrant snapshot restore clean-oel8
# Restore without restarting VM
vagrant snapshot restore clean-oel8 --no-start
# Delete a snapshot
vagrant snapshot delete clean-oel8
# Delete snapshot of specific machine
vagrant snapshot delete master mysql-installed
Push/Pop Snapshots (Stack)
BASH — Push/Pop Snapshots
# Push current state onto snapshot stack
vagrant snapshot push
# Pop last snapshot (restores and deletes it)
vagrant snapshot pop
# Pop without deleting (just restore, keep snapshot)
vagrant snapshot pop --no-delete
# Example workflow:
vagrant snapshot push # Save state before risky change
mysql -u root -p < migration.sql # Run migration (via port forward)
# If migration fails:
vagrant snapshot pop # Restore instantly!
Database Snapshot Workflows
Workflow 1 — Before MySQL Upgrade
BASH — Before Upgrade Snapshot
# Start fresh VM with MySQL 8.0.33
vagrant up
# Take snapshot after base install
vagrant snapshot save mysql-8.0.33-clean
# Upgrade to 8.0.36
vagrant ssh master -c "sudo dnf upgrade mysql-community-server"
# Something wrong? Rollback instantly
vagrant snapshot restore mysql-8.0.33-clean
# Upgrade successful? Take new snapshot
vagrant snapshot save mysql-8.0.36-clean
Workflow 2 — Before Schema Migration
BASH — Schema Migration Snapshot
# Before running DDL changes
vagrant snapshot push
# Run migration
vagrant ssh master -c "mysql -u root -pRoot@123! mydb < /vagrant/sql/v2_migration.sql"
# Test application
# If tests fail:
vagrant snapshot pop # Instant rollback
# If tests pass:
# Continue — snapshot is still there as safety net
Workflow 3 — Multiple Lab States
BASH — Multiple Lab States
# Snapshot 1: Clean OEL 8
vagrant snapshot save "01-clean-oel8"
# Snapshot 2: MySQL installed
vagrant snapshot save "02-mysql-installed"
# Snapshot 3: Replication configured
vagrant snapshot save "03-replication-done"
# Snapshot 4: ProxySQL added
vagrant snapshot save "04-proxysql-added"
# Jump to any state:
vagrant snapshot restore "02-mysql-installed"
# Now at MySQL installed state — ProxySQL not there yet
vagrant snapshot restore "04-proxysql-added"
# Jump back to full setup
VirtualBox Snapshot Notes
BASH — VBoxManage Snapshots
# VirtualBox snapshots can also be managed via VBoxManage
# List snapshots
VBoxManage snapshot "OEL8-Master" list
# Take snapshot via VBoxManage
VBoxManage snapshot "OEL8-Master" take "mysql-installed" --description "MySQL 8 installed"
# Restore via VBoxManage
VBoxManage snapshot "OEL8-Master" restore "mysql-installed"
# Delete via VBoxManage
VBoxManage snapshot "OEL8-Master" delete "mysql-installed"
Snapshot Best Practices
- Use descriptive names — "mysql-8.0.36-clean" is better than "snapshot1"
- Take a snapshot before every major change — upgrades, migrations, config changes
- Snapshots consume disk space — delete old ones you no longer need
- Snapshots do not replace backups — they only exist as long as the VM exists
- For multi-machine setups, always specify the machine name in snapshot commands
⚠ Warning: Snapshots are stored inside your VirtualBox VM folder. If you destroy the VM with vagrant destroy, all snapshots are lost permanently.