HyperSDK provides comprehensive Proxmox Virtual Environment integration supporting VM management via the Proxmox VE REST API. The implementation includes backup creation via vzdump, VM control operations, and retry mechanisms for reliable operations.
# Install Go 1.24+
sudo dnf install golang # Fedora/RHEL
sudo apt install golang # Ubuntu/Debian
# Install HyperSDK
git clone https://github.com/ssahani/hypersdk
cd hypersdk
go build ./cmd/hyperexport
go build ./cmd/hypervisord
go build ./cmd/hyperctl
Create /etc/hypervisord/config.yaml:
proxmox:
# Connection Settings
host: "proxmox.example.com" # Proxmox VE host
port: 8006 # API port (default: 8006)
# Authentication
username: "root@pam" # Format: user@realm
password: "your-password" # Or use API token
# Optional: API Token Authentication (recommended)
token_id: "root@pam!token-id"
token_secret: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# Default Settings
node: "pve1" # Default Proxmox node
storage: "local" # Storage for backups
# Security
verify_ssl: false # Set to true for production with valid certs
enabled: true
# Proxmox Authentication
export PROXMOX_HOST="proxmox.example.com"
export PROXMOX_USERNAME="root@pam"
export PROXMOX_PASSWORD="your-password"
export PROXMOX_NODE="pve1"
# For API tokens
export PROXMOX_TOKEN_ID="root@pam!token-id"
export PROXMOX_TOKEN_SECRET="token-secret"
# List all VMs across all nodes
./hyperctl -provider proxmox list
# Using API
curl http://localhost:8080/proxmox/vms
# Interactive export
./hyperexport -provider proxmox -vm 100
# With node specification
./hyperexport -provider proxmox -vm pve1:100
# Non-interactive with options
./hyperexport \
-provider proxmox \
-vm 100 \
-output /backup/exports \
-compress
# Create VM backup
curl -X POST http://localhost:8080/proxmox/backup \
-H "Content-Type: application/json" \
-d '{
"node": "pve1",
"vmid": 100,
"mode": "snapshot",
"compress": "zstd"
}'
# Stop VM
curl -X POST http://localhost:8080/proxmox/vms/100/stop
# Start VM
curl -X POST http://localhost:8080/proxmox/vms/100/start
Proxmox supports three backup modes:
backup_mode: "snapshot" # Uses LVM/ZFS snapshots, VM stays online
backup_mode: "suspend" # Suspends VM during backup
backup_mode: "stop" # Stops VM before backup
Choose compression based on your needs:
compress: "zstd" # Best balance of speed and compression
compress: "gzip" # Standard compression
compress: "lzo" # Fastest compression
proxmox:
username: "root@pam" # Format: user@realm
password: "password"
Supported realms:
pam - Linux PAMpve - Proxmox VE authenticationad - Active Directoryldap - LDAPCreate an API token in Proxmox Web UI:
proxmox:
username: "root@pam"
token_id: "root@pam!hypersdk"
token_secret: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
import "hypersdk/providers/proxmox"
// Create client
client, err := proxmox.NewClient(cfg, logger)
// List nodes
nodes, err := client.ListNodes(ctx)
// List VMs on a node
vms, err := client.ListVMs(ctx, "pve1")
// Get VM details
vm, err := client.GetVM(ctx, "pve1", 100)
// Power management
err = client.StopVM(ctx, "pve1", 100)
err = client.StartVM(ctx, "pve1", 100)
// Backups
result, err := client.ExportVM(ctx, ExportOptions{
Node: "pve1",
VMID: 100,
OutputPath: "/backup",
BackupMode: "snapshot",
Compress: "zstd",
})
Authentication Failed:
Error: authentication failed with status 401
Solution: Check username/password or API token
VM Not Found:
Error: VM with VMID 100 not found on any node
Solution: Verify VMID and node name
Insufficient Permissions:
Error: 403 Forbidden
Solution: Grant required permissions in Proxmox (VM.Backup, VM.PowerMgmt)
Storage Full:
Error: not enough space on storage 'local'
Solution: Clean up old backups or use different storage
Enable debug logging:
export LOG_LEVEL=debug
./hyperexport -provider proxmox -vm 100
Create a role with these privileges:
VM.Audit - View VM configuration and status
VM.Backup - Create and restore backups
VM.PowerMgmt - Start/stop/shutdown VMs
Datastore.Audit - View storage
Datastore.AllocateSpace - Allocate storage for backups
# Via Proxmox shell
pveum role add HyperSDK -privs \
VM.Audit,VM.Backup,VM.PowerMgmt,Datastore.Audit,Datastore.AllocateSpace
# Assign to user
pveum acl modify / -user hypersdk@pve -role HyperSDK
import requests
import time
BASE_URL = "http://localhost:8080"
# Create backup
response = requests.post(f"{BASE_URL}/proxmox/backup", json={
"node": "pve1",
"vmid": 100,
"mode": "snapshot",
"compress": "zstd"
})
backup_id = response.json()["backup_id"]
# Wait for completion
while True:
response = requests.get(f"{BASE_URL}/proxmox/tasks/{backup_id}")
status = response.json()["status"]
if status == "stopped":
print("Backup complete!")
break
time.sleep(5)
#!/bin/bash
NODE="pve1"
VMID=100
BACKUP_DIR="/backup/proxmox"
# Create backup
echo "Creating backup of VM $VMID..."
./hyperexport \
-provider proxmox \
-vm $NODE:$VMID \
-output $BACKUP_DIR \
-compress
echo "Backup complete!"
# Test API access
curl -k https://proxmox.example.com:8006/api2/json/version
# Test authentication
curl -k -X POST https://proxmox.example.com:8006/api2/json/access/ticket \
-d "username=root@pam&password=yourpassword"
# Check HyperSDK status
./hyperctl status
# Test Proxmox provider
curl http://localhost:8080/providers/proxmox/health
verify_ssl: true)/var/log/pve/tasks/ for suspicious activity# Increase workers for faster multi-VM exports
download_workers: 6 # Default: 4
Use fast storage for backups:
# Adjust timeouts for slow networks
proxmox:
timeout: 600s # Increase for large VMs
LGPL-3.0-or-later - See LICENSE file for details