VPS Snapshots
Complete guide to creating, managing, and restoring VPS snapshots for backup and cloning purposes.
What are Snapshots?
Snapshots are point-in-time copies of your VPS instance, including:
- Operating system and all files
- Applications and configurations
- Data stored on the instance
- Complete system state at capture time
Snapshots vs Backups
| Feature | Snapshots | Traditional Backups |
|---|---|---|
| Speed | Very fast (minutes) | Slower (hours) |
| Downtime | None required | May require downtime |
| Restore | Complete system restore | File-level restore |
| Use Case | System cloning, migrations | Data recovery |
| Storage | Block-level | File-level |
Why Use Snapshots?
Backup Before Changes
Take a snapshot before:
- System updates
- Application upgrades
- Configuration changes
- Installing new software
- Database migrations
Disaster Recovery
- Quick recovery from failures
- Protection against mistakes
- Rollback bad deployments
- Restore corrupted systems
Cloning & Scaling
- Create identical instances
- Scale horizontally
- Test environments
- Development copies
Migration
- Move to different region
- Upgrade instance size
- Change configurations
- Platform migration
Creating Snapshots
Via Dashboard
- Navigate to Pods (VPS)
- Click on your instance name
- Go to Snapshots tab
- Click Create Snapshot
- Enter snapshot details:
- Name: Descriptive name
- Description: Purpose and context
- Click Create
Creation Time: 2-5 minutes depending on disk size
Snapshot Naming Best Practices
Good Names:
pre-update-2024-10-11
before-nginx-upgrade
production-backup-daily
staging-clone-v2
migration-source
Poor Names:
snapshot1
backup
test
my-snapshot
Naming Convention
[environment]-[purpose]-[date]
prod-pre-deploy-2024-10-11
staging-backup-2024-10-11
dev-clone-2024-10-11
Snapshot Details
What's Included
✅ Operating System: All OS files
✅ Applications: Installed software
✅ Configurations: All config files
✅ Data: Application data, databases
✅ Users: User accounts and permissions
✅ Logs: System and application logs
What's NOT Included
❌ RAM Contents: Active memory state
❌ Network Connections: Active connections
❌ Temporary Files: /tmp contents may vary
❌ Process State: Running processes
Best Practices Before Snapshot
Stop Services (optional but recommended):
# Stop database sudo systemctl stop mysql # Stop application sudo systemctl stop nginxFlush Caches:
# Sync filesystem sync # Drop caches sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'Database Backup:
# MySQL mysqldump -u root -p --all-databases > backup.sql # PostgreSQL pg_dumpall > backup.sqlDocument State:
- Running services
- Important processes
- Configuration details
Managing Snapshots
View Snapshots
- Go to VPS instance page
- Click Snapshots tab
- See all snapshots:
- Name and description
- Creation date
- Size
- Status
Snapshot Statuses
- Creating: Snapshot in progress
- Available: Ready to use
- Restoring: Being restored
- Deleting: Being removed
- Error: Failed creation/restore
Delete Snapshot
Warning: Deletion is permanent!
- Go to Snapshots tab
- Click Delete next to snapshot
- Confirm deletion
- Snapshot removed immediately
Note: You're charged for snapshot storage until deleted.
Restoring from Snapshots
Restore to Existing Instance
Warning: This will overwrite your current instance!
- Backup current data if needed
- Go to Snapshots tab
- Click Restore next to snapshot
- Select Restore to Existing Instance
- Confirm action
- Wait 5-10 minutes
What Happens:
- Instance stops
- Data replaced with snapshot
- Instance reboots
- You may lose data created after snapshot
Create New Instance from Snapshot
Safer option - doesn't affect existing instance:
- Go to Snapshots tab
- Click Restore next to snapshot
- Select Create New Instance
- Configure new instance:
- Name: New instance name
- Profile: Can change size
- Region: Can change location
- Click Create
Result: New instance identical to snapshot state
After Restore
Verify System:
# Check system status uptime df -h free -h # Verify services sudo systemctl status nginx sudo systemctl status mysqlUpdate Configurations:
- Update IP addresses
- Update DNS records
- Update environment variables
- Update API endpoints
Start Services:
sudo systemctl start nginx sudo systemctl start mysql sudo systemctl start your-app
Snapshot Use Cases
Use Case 1: Safe System Updates
Scenario: Ubuntu system update
# 1. Create snapshot via dashboard
# Name: "pre-update-2024-10-11"
# 2. Perform update
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
# 3. Test system
# If problems occur, restore from snapshot
# If all good, keep running
# 4. Delete old snapshot after confirmed working
Use Case 2: Application Deployment
Scenario: Deploy new application version
# 1. Create snapshot
# Name: "pre-deploy-v2.0"
# 2. Deploy new version
git pull origin main
npm install
npm run build
sudo systemctl restart app
# 3. Test thoroughly
# If issues, restore snapshot
# If successful, keep and delete old snapshot
Use Case 3: Development Environment
Scenario: Create dev copy of production
- Create snapshot of production instance
- Restore to new instance
- Rename new instance to "dev-environment"
- Update configurations:
- Change database credentials
- Update API keys (use test keys)
- Disable production integrations
- Update application URLs
Use Case 4: Horizontal Scaling
Scenario: Add more web servers
Prepare one server perfectly:
- Install all software
- Configure everything
- Test thoroughly
Create snapshot "web-server-template"
Create multiple instances from snapshot:
- web-server-01
- web-server-02
- web-server-03
Configure load balancer to distribute traffic
Use Case 5: Migration
Scenario: Move to larger instance
- Create snapshot of current instance
- Create new instance from snapshot
- Choose larger profile
- Same region (or different)
- Test new instance
- Update DNS to point to new instance
- Delete old instance
- Delete old snapshot
Automation with API
Create Snapshot
import requests
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
data = {
"name": f"auto-backup-{datetime.now().strftime('%Y-%m-%d')}",
"description": "Automated daily backup"
}
response = requests.post(
"https://api.danubedata.com/v1/vps/vps-abc123/snapshots",
headers=headers,
json=data
)
snapshot = response.json()
print(f"Snapshot created: {snapshot['data']['id']}")
List Snapshots
response = requests.get(
"https://api.danubedata.com/v1/vps/vps-abc123/snapshots",
headers=headers
)
snapshots = response.json()["data"]
for snap in snapshots:
print(f"{snap['name']}: {snap['created_at']}")
Automated Daily Backup Script
#!/usr/bin/env python3
import requests
import os
from datetime import datetime, timedelta
API_TOKEN = os.environ['DANUBEDATA_API_TOKEN']
VPS_ID = "vps-abc123"
RETENTION_DAYS = 7
headers = {
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
}
# Create new snapshot
data = {
"name": f"daily-backup-{datetime.now().strftime('%Y-%m-%d')}",
"description": f"Automated backup - {datetime.now()}"
}
response = requests.post(
f"https://api.danubedata.com/v1/vps/{VPS_ID}/snapshots",
headers=headers,
json=data
)
if response.status_code == 201:
print(f"Snapshot created successfully")
else:
print(f"Error: {response.json()}")
exit(1)
# Delete old snapshots
response = requests.get(
f"https://api.danubedata.com/v1/vps/{VPS_ID}/snapshots",
headers=headers
)
snapshots = response.json()["data"]
cutoff_date = datetime.now() - timedelta(days=RETENTION_DAYS)
for snap in snapshots:
snap_date = datetime.fromisoformat(snap['created_at'].replace('Z', '+00:00'))
if snap_date < cutoff_date and snap['name'].startswith('daily-backup'):
print(f"Deleting old snapshot: {snap['name']}")
requests.delete(
f"https://api.danubedata.com/v1/vps/{VPS_ID}/snapshots/{snap['id']}",
headers=headers
)
Schedule with Cron:
# Add to crontab
0 2 * * * /usr/local/bin/backup-vps.py
Snapshot Pricing
Storage Costs
- Price: $0.05 per GB per month
- Billed: Hourly (prorated)
- Size: Based on used disk space
Cost Examples
| Instance Size | Used Space | Monthly Cost |
|---|---|---|
| 25 GB disk | 10 GB used | $0.50 |
| 50 GB disk | 25 GB used | $1.25 |
| 80 GB disk | 40 GB used | $2.00 |
| 160 GB disk | 80 GB used | $4.00 |
Cost Optimization
- Delete old snapshots regularly
- Clean disk before snapshot:
sudo apt clean sudo journalctl --vacuum-time=7d docker system prune -a - Keep only necessary snapshots
- Use compression before snapshot
- Remove unused files
Best Practices
Regular Snapshots
Daily Production:
- Before any changes
- Automated nightly backups
- Keep 7 days
Weekly Development:
- End of sprint
- Before major updates
- Keep 4 weeks
Pre-Change Always:
- Before system updates
- Before deployments
- Before configuration changes
Naming Strategy
[frequency]-[environment]-[date]
daily-prod-2024-10-11
weekly-staging-2024-10-11
pre-deploy-prod-2024-10-11
Testing Restores
Monthly: Test restore process
- Create test instance from snapshot
- Verify all services work
- Confirm data integrity
- Document restore time
- Delete test instance
Documentation
Keep a snapshot log:
Date | Name | Purpose | Retention
-----------|-------------------|-------------------|----------
2024-10-11 | pre-update-v2 | Before Ubuntu 24 | 30 days
2024-10-11 | daily-prod | Daily backup | 7 days
2024-10-10 | pre-deploy-api | Before API v3 | 14 days
Troubleshooting
Snapshot Creation Fails
Check:
- Disk space available
- Instance is running
- No other operations in progress
- Account limits not exceeded
Solution:
# Free up space
sudo apt clean
sudo journalctl --vacuum-time=7d
rm -rf /tmp/*
# Check disk
df -h
Restore Fails
Possible Causes:
- Insufficient resources
- Snapshot corrupted
- Network issues
Solution:
- Try again
- Contact support
- Use different snapshot
- Check system logs
Slow Snapshot Creation
Factors:
- Disk size
- Data amount
- Disk activity
- Network speed
Optimization:
- Stop services temporarily
- Reduce disk I/O
- Schedule during low-traffic
- Clean disk before snapshot
Limitations
Size Limits
- Maximum snapshot size: Based on disk size
- Storage per account: Check account limits
Quantity Limits
- Snapshots per instance: 50 (default)
- Request increase if needed
Region Restrictions
- Snapshots tied to region
- Can restore to different region
- Cross-region may take longer
Time Limits
- Creation time: 2-10 minutes
- Restore time: 5-15 minutes
- Depends on size
Security Considerations
Data Protection
✅ Encrypted at Rest: All snapshots encrypted
✅ Access Control: Only account members can access
✅ Isolated Storage: Separate from instance storage
✅ Backup Redundancy: Multiple copies maintained
Sensitive Data
Before Snapshot:
- Review for sensitive data
- Remove temporary secrets
- Clear logs with sensitive info
- Document included credentials
After Restore:
- Rotate credentials
- Update API keys
- Change passwords
- Verify access controls
Next Steps
Need help with snapshots? Contact support through the dashboard.