cv4pve-autosnap is an automatic snapshot tool designed for Proxmox VE virtual machines and containers. It streamlines backup processes by creating snapshots with retention policies, ensuring efficient data management.
Key Features:
Automatic snapshot creation with configurable retention policies to manage data effectively.
Support for both virtual machines (VMs) and containers within the Proxmox VE environment.
Integration capabilities through pre/post snapshot hook scripts for customized automation workflows.
Utilization of multiple labels to organize snapshots according to different schedules or purposes.
Audience & Benefit:
Ideal for system administrators managing Proxmox VE environments, cv4pve-autosnap provides reliable backups and efficient data management. Its features enhance flexibility in targeting specific VMs or containers, integrate seamlessly with existing automation scripts, and maintain data integrity through retention policies.
This tool can be installed via winget, offering a straightforward setup process for users familiar with Proxmox VE environments.
# Check available releases at: https://github.com/Corsinvest/cv4pve-autosnap/releases
# Download specific version (replace VERSION with actual version number)
wget https://github.com/Corsinvest/cv4pve-autosnap/releases/download/VERSION/cv4pve-autosnap-linux-x64.zip
unzip cv4pve-autosnap-linux-x64.zip
# Create snapshot with retention
./cv4pve-autosnap --host=YOUR_HOST --username=root@pam --password=YOUR_PASSWORD --vmid=100 snap --label=daily --keep=7
# Clean old snapshots
./cv4pve-autosnap --host=YOUR_HOST --username=root@pam --password=YOUR_PASSWORD --vmid=100 clean --label=daily
Intelligent retention with configurable keep policies
Multiple schedules using labels (daily, weekly, monthly)
Hook scripts for custom automation
Memory state preservation with --state
Storage monitoring with capacity checks
Enterprise Features
API token support (Proxmox VE 6.2+)
SSL validation options
Timeout management for operations
Error resilience (no stop on error)
Comprehensive logging and status reporting
Installation
Linux Installation
# Check available releases and get the specific version number
# Visit: https://github.com/Corsinvest/cv4pve-autosnap/releases
# Download specific version (replace VERSION with actual version like v1.2.3)
wget https://github.com/Corsinvest/cv4pve-autosnap/releases/download/VERSION/cv4pve-autosnap-linux-x64.zip
# Alternative: Get latest release URL programmatically
LATEST_URL=$(curl -s https://api.github.com/repos/Corsinvest/cv4pve-autosnap/releases/latest | grep browser_download_url | grep linux-x64 | cut -d '"' -f 4)
wget "$LATEST_URL"
# Extract and make executable
unzip cv4pve-autosnap-linux-x64.zip
chmod +x cv4pve-autosnap
# Optional: Move to system path
sudo mv cv4pve-autosnap /usr/local/bin/
Windows Installation
Option 1: Winget (Recommended)
# Install using Windows Package Manager
winget install Corsinvest.cv4pve-autosnap
Option 2: Manual Installation
# Check available releases at: https://github.com/Corsinvest/cv4pve-autosnap/releases
# Download specific version (replace VERSION with actual version)
Invoke-WebRequest -Uri "https://github.com/Corsinvest/cv4pve-autosnap/releases/download/VERSION/cv4pve-autosnap-win-x64.zip" -OutFile "cv4pve-autosnap.zip"
# Extract
Expand-Archive cv4pve-autosnap.zip -DestinationPath "C:\Tools\cv4pve-autosnap"
# Add to PATH (optional)
$env:PATH += ";C:\Tools\cv4pve-autosnap"
macOS Installation
# Check available releases at: https://github.com/Corsinvest/cv4pve-autosnap/releases
# Download specific version (replace VERSION with actual version)
wget https://github.com/Corsinvest/cv4pve-autosnap/releases/download/VERSION/cv4pve-autosnap-osx-x64.zip
unzip cv4pve-autosnap-osx-x64.zip
chmod +x cv4pve-autosnap
# Move to applications
sudo mv cv4pve-autosnap /usr/local/bin/
# Use interactive password prompt that stores to file
cv4pve-autosnap --host=192.168.1.100 --username=backup@pve --password=file:/etc/cv4pve/password [commands]
# First run: prompts for password and saves to file
# Subsequent runs: reads password from file automatically
VM/CT Selection Patterns
The --vmid parameter supports powerful pattern matching based on the GetVmsAsync method with jolly patterns:
Pattern
Syntax
Description
Example
Single ID
ID
Specific VM/CT by ID
--vmid=100
Single Name
name
Specific VM/CT by name
--vmid=web-server
Multiple IDs
ID,ID,ID
Comma-separated list
--vmid=100,101,102
Mixed ID/Names
ID,name,ID
Mix IDs and names
--vmid=100,web-server,102
ID Ranges
start:end
Range of IDs (inclusive)
--vmid=100:110
Complex Ranges
start:end,ID,start:end
Multiple ranges and IDs
--vmid=100:107,200,300:305
Wildcard Names
%pattern%
Contains pattern
--vmid=%web%,%db%
Prefix Match
pattern%
Starts with pattern
--vmid=web%,db%
Suffix Match
%pattern
Ends with pattern
--vmid=%server,%prod
All VMs
@all
All VMs in cluster
--vmid=@all
All on Node
@all-node
All VMs on specific node
--vmid=@all-pve1
All on Current
@all-$(hostname)
All VMs on current host
--vmid=@all-$(hostname)
Pool Selection
@pool-name
All VMs in specific pool
--vmid=@pool-production
Tag Selection
@tag-name
All VMs with specific tag
--vmid=@tag-backup
Node Selection
@node-name
All VMs on specific node
--vmid=@node-pve1
Node Current
@node-$(hostname)
All VMs on current host
--vmid=@node-$(hostname)
Exclusions
-ID or -name
Exclude specific VM/CT
--vmid=@all,-100,-test-vm
Wildcard Exclusions
-%pattern%
Exclude pattern matches
--vmid=@all,-%test%,-%dev%
Range Exclusions
-start:end
Exclude range of IDs
--vmid=@all,-200:299
Tag Exclusions
-@tag-name
Exclude VMs with tag
--vmid=@all,-@tag-test
Pool Exclusions
-@pool-name
Exclude pool VMs
--vmid=@pool-prod,-@pool-dev
Node Exclusions
-@node-name
Exclude node VMs
--vmid=@all,-@node-pve2
Pattern Examples
Real-World Selection Examples
Basic Selections
# Single VM by ID
--vmid=100
# Single VM by name
--vmid=database-server
# Multiple VMs mixed
--vmid=100,web-server,102,mail-server
# Range of VMs
--vmid=100:110
# Complex ranges
--vmid=100:107,-105,200:204,300
# Wildcard patterns with %
--vmid=web%,db%,%server # web*, db*, *server
--vmid=%test%,%dev% # *test*, *dev*
Advanced Pool & Tag Selections
# All VMs in production pool
--vmid=@pool-production
# All VMs tagged as critical
--vmid=@tag-critical
# All VMs on specific node
--vmid=@node-pve1
# All VMs on current hostname
--vmid=@node-$(hostname)
Exclusion Patterns
# All VMs except specific IDs
--vmid=@all,-100,-101
# All VMs except by name
--vmid=@all,-test-vm,-backup-server
# All VMs except wildcard patterns
--vmid=@all,-%test%,-%dev%
# All VMs except range
--vmid=@all,-200:299
# Production pool except test tagged
--vmid=@pool-production,-@tag-test
# All except specific node
--vmid=@all,-@node-pve2
# Complex exclusions with wildcards
--vmid=@all,-100:110,-@tag-development,-%test%
Wildcard Pattern Examples
# Contains pattern (equivalent to *web* in shell)
--vmid=%web% # Matches: web-server, my-web-app, web01
# Starts with pattern (equivalent to web* in shell)
--vmid=web% # Matches: web-server, webmail, web01
# Ends with pattern (equivalent to *server in shell)
--vmid=%server # Matches: web-server, mail-server, db-server
# Multiple wildcard patterns
--vmid=web%,db%,%prod # web*, db*, *prod
# Complex selections with wildcards
--vmid=%web%,%db%,100:110,mail-server
# Exclude wildcard patterns
--vmid=@all,-%test%,-%dev%,-%staging%
cv4pve-autosnap --host=pve.domain.com --username=root@pam --password=secret --vmid=100 status
JSON output for automation
cv4pve-autosnap --host=pve.domain.com --api-token=backup@pve!token=uuid --vmid=@all status --output=json
Advanced Targeting Examples
Production Environment Patterns
# Backup all production VMs tagged as 'critical'
cv4pve-autosnap --host=cluster.company.com --api-token=backup@pve!prod=uuid --vmid=@tag-critical snap --label=critical-daily --keep=14
# Backup entire customer pool except test VMs
cv4pve-autosnap --host=pve.company.com --username=backup@pve --password=secret --vmid="@pool-customer1,-@tag-test" snap --label=customer-backup --keep=30
# Node-specific backup with range exclusion
cv4pve-autosnap --host=pve-cluster.local --api-token=ops@pve!node1=uuid --vmid="@node-pve1,-200:299" snap --label=node1-backup --keep=7
Scheduling with Cron
Cron Examples
# Edit crontab
crontab -e
# Daily backup at 2 AM (keep 7 days)
0 2 * * * /usr/local/bin/cv4pve-autosnap --host=pve.local --api-token=backup@pve!daily=uuid --vmid=@tag-production snap --label=daily --keep=7
# Weekly backup on Sunday at 3 AM (keep 4 weeks)
0 3 * * 0 /usr/local/bin/cv4pve-autosnap --host=pve.local --api-token=backup@pve!weekly=uuid --vmid=@all snap --label=weekly --keep=4 --state
# Monthly cleanup on 1st day at 4 AM
0 4 1 * * /usr/local/bin/cv4pve-autosnap --host=pve.local --api-token=backup@pve!cleanup=uuid --vmid=@all clean --label=old-snapshots
Security & Permissions
Required Permissions
Permission
Purpose
Scope
VM.Audit
Read VM/CT information
Virtual machines
VM.Snapshot
Create/delete snapshots
Virtual machines
Datastore.Audit
Check storage capacity
Storage systems
Pool.Audit
Access pool information
Resource pools
API Token Setup (Recommended)
Creating API Tokens
1. Generate API Token and Configure Permissions
# Follow Proxmox VE documentation for:
# - API token creation with proper privilege separation
# - Permission assignment for required roles
# - Required permissions: VM.Audit, VM.Snapshot, Datastore.Audit, Pool.Audit
# Refer to official Proxmox VE API documentation for detailed steps
Metrics: send-metrics.sh (for sending metrics to monitoring systems)
These scripts provide templates with all available environment variables and phase handling logic that you can customize for your automation needs.
Example Hook Script
#!/bin/bash
# /usr/local/bin/cv4pve-hook.sh
case $CV4PVE_AUTOSNAP_PHASE in
"pre-snapshot")
echo "$(date): Starting snapshot for VM $CV4PVE_AUTOSNAP_VMID"
# Send notification to monitoring system
curl -X POST "https://monitoring.company.com/api/events" -d "{'type':'snapshot_start','vm':'$CV4PVE_AUTOSNAP_VMID'}"
;;
"post-snapshot")
echo "$(date): Completed snapshot $CV4PVE_AUTOSNAP_SNAP_NAME"
# Log to central system
logger "cv4pve-autosnap: Created snapshot $CV4PVE_AUTOSNAP_SNAP_NAME for VM $CV4PVE_AUTOSNAP_VMID"
;;
esac
Use descriptive labels (daily, weekly, before-update)
Include environment in label (prod-daily, dev-weekly)
Consider compliance requirements (retention-7y)
Performance Optimization
Schedule during low activity periods
Stagger snapshot times across VMs
Monitor storage growth regularly
Use memory state sparingly (larger snapshots)
Implement cleanup routines for old snapshots
Reliability Measures
Test restore procedures regularly
Monitor snapshot creation for failures
Implement alerting for storage thresholds
Document recovery procedures
Verify QEMU agent installation
Troubleshooting
Common Issues & Solutions
Authentication Problems
Issue: "Authentication failed"
# Check credentials
cv4pve-autosnap --host=pve.local --username=root@pam --password=test --vmid=100 status
# Verify API token format
cv4pve-autosnap --host=pve.local --api-token=user@realm!tokenid=uuid --vmid=100 status
Solution: Verify permissions
# Check user permissions in Proxmox
pveum user list
pveum user permissions backup@pve
Connection Issues
Issue: "Connection timeout" or "Host unreachable"
# Test connectivity
ping pve.local
telnet pve.local 8006
# Check SSL certificate
cv4pve-autosnap --host=pve.local --validate-certificate --username=root@pam --password=secret --vmid=100 status
Solution: Network and certificate verification
# Use IP instead of hostname
cv4pve-autosnap --host=192.168.1.100 ...
# Disable SSL validation for testing (not recommended for production)
cv4pve-autosnap --host=pve.local --username=root@pam --password=secret --vmid=100 status
Storage Issues
Issue: "Storage space insufficient"
# Check storage status
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 status
# Debug VM selection
cv4pve-autosnap --host=pve.local --api-token=token --vmid=@tag-nonexistent status
Solution: Verify VM tags and pools
# List all VMs to verify IDs/names
cv4pve-autosnap --host=pve.local --api-token=token --vmid=@all status
# Check specific pool
cv4pve-autosnap --host=pve.local --api-token=token --vmid=@pool-production status
Debug Mode
Enable Detailed Logging
# Enable debug output
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 --debug snap --label=debug-test --keep=1
# Test run without making changes
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 --dry-run snap --label=test --keep=3
> Important: Without QEMU Guest Agent, snapshots are like "pulling the power plug" on your VM. The agent ensures filesystem consistency during snapshot operations.
Without Guest Agent
Inconsistent filesystem state
Potential data corruption
Half-written files
Requires fsck on boot
Application data loss risk
With Guest Agent
Filesystem sync before snapshot
I/O freeze during operation
Clean application state
Reliable snapshot consistency
Database-safe operations
Guest Agent Verification
# Check if guest agent is working
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 status
# Look for agent warnings in output:
# "VM 100 consider enabling QEMU agent see https://pve.proxmox.com/wiki/Qemu-guest-agent"
# Clean old daily snapshots (keep newest 7)
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 clean --label=daily --keep=7
# Remove all snapshots with specific label
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 clean --label=old-backup --keep=0
# Clean across multiple VMs
cv4pve-autosnap --host=pve.local --api-token=token --vmid=@pool-development clean --label=test --keep=0
Status Command
Snapshot Status & Reporting
cv4pve-autosnap [global-options] status [status-options]
Status Output Formats
# Table format (default)
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 status
# JSON format for automation
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 status --output=json
# Pretty JSON for debugging
cv4pve-autosnap --host=pve.local --api-token=token --vmid=100 status --output=jsonpretty