CLI Tool
Command-line interface for LOX Backup. Perfect for scripts, cron jobs, and automation.
v0.1.0Updated 2026-01-01
Installation
pip install lox-backup[cli]
Requirements
- Python 3.8 or higher
- pip package manager
Configuration
Set API Key
# Configure your API key (stored securely) lox config set api_key your-api-key # Verify configuration lox config show
Environment Variables
Alternatively, use environment variables:
export LOX_API_KEY="your-api-key" export LOX_API_URL="https://backlox.com/api" # Optional
Configuration File
The CLI stores configuration in ~/.lox/config.json:
{
"api_key": "your-api-key",
"api_url": "https://backlox.com/api",
"default_retention_days": 30,
"default_tags": ["automated"]
}Commands
lox backup upload
Upload a file to LOX cold storage.
# Basic upload lox backup upload backup.tar.gz # Upload with options lox backup upload backup.tar.gz \ --name "production-db-2024-01-15" \ --tags "production,database,mysql" \ --retention 90 \ --description "Daily production backup" # Wait for completion lox backup upload backup.tar.gz --wait # Upload with timeout lox backup upload large-backup.tar.gz --wait --timeout 3600
Options
| Option | Description |
|---|---|
| --name, -n | Backup name (defaults to filename) |
| --tags, -t | Comma-separated tags |
| --retention, -r | Retention days (default: 30) |
| --description, -d | Backup description |
| --wait, -w | Wait for processing to complete |
| --timeout | Max wait time in seconds (default: 3600) |
| --quiet, -q | Minimal output |
| --json | Output as JSON |
lox backup list
List backups in your account.
# List all backups lox backup list # Filter by status lox backup list --status completed lox backup list --status pending # Filter by tags lox backup list --tags production lox backup list --tags "database,mysql" # Search by name lox backup list --search "prod" # Pagination lox backup list --limit 20 --offset 0 # Output as JSON lox backup list --json # Output as table (default) lox backup list --format table
lox backup get
Get details of a specific backup.
# Get backup by UUID lox backup get 550e8400-e29b-41d4-a716-446655440000 # Output as JSON lox backup get 550e8400-e29b-41d4-a716-446655440000 --json
lox backup download
Download a backup to local storage.
# Download backup lox backup download 550e8400-e29b-41d4-a716-446655440000 # Specify output file lox backup download 550e8400-e29b-41d4-a716-446655440000 \ --output ./restored-backup.tar.gz # Download to specific directory lox backup download 550e8400-e29b-41d4-a716-446655440000 \ --output-dir ./backups/
lox backup delete
Delete a backup.
# Delete backup (with confirmation) lox backup delete 550e8400-e29b-41d4-a716-446655440000 # Delete without confirmation lox backup delete 550e8400-e29b-41d4-a716-446655440000 --yes # Delete multiple backups lox backup delete uuid1 uuid2 uuid3 --yes
lox backup restore
Get a restore/download URL for a backup.
# Get download URL lox backup restore 550e8400-e29b-41d4-a716-446655440000 # Output just the URL (for scripting) lox backup restore 550e8400-e29b-41d4-a716-446655440000 --url-only
lox auth status
Check authentication status and API key validity.
# Check if API key is valid lox auth status # Output as JSON lox auth status --json
lox tenant info
Show tenant information and quota.
# Show tenant info lox tenant info # Show quota only lox tenant quota # Output as JSON lox tenant info --json
lox storage list
List storage targets and health.
# List storage targets lox storage list # Show health summary lox storage health
lox notifications
Manage notification channels for backup alerts.
# List notification channels lox notifications list # Get channel types and available events lox notifications types # Create a webhook channel lox notifications create webhook "Production Alerts" \ --url "https://example.com/webhook" \ --events "backup_completed,backup_failed" # Create a Slack channel lox notifications create slack "Slack Alerts" \ --webhook-url "https://hooks.slack.com/services/..." \ --channel "#backup-alerts" # Create a Discord channel lox notifications create discord "Discord Alerts" \ --webhook-url "https://discord.com/api/webhooks/..." # Get channel details lox notifications get <channel-uuid> # Get channel summary lox notifications summary # Test a channel lox notifications test <channel-uuid> # Enable/disable a channel lox notifications enable <channel-uuid> lox notifications disable <channel-uuid> # Update channel lox notifications update <channel-uuid> --name "New Name" lox notifications update <channel-uuid> --regenerate-secret # Delete a channel lox notifications delete <channel-uuid> --yes
lox agents
Manage backup agents for machine backup.
# List agents lox agents list # Get agent summary lox agents summary # Register a new agent lox agents register "server-01" \ --os-type linux \ --display-name "Production Server 01" \ --capabilities "file,block" # Get agent details lox agents get <agent-uuid> # Get install command lox agents install-command <agent-uuid> # Enable/disable agent lox agents enable <agent-uuid> lox agents disable <agent-uuid> # Update agent lox agents update <agent-uuid> --display-name "New Name" # Regenerate agent token lox agents regenerate-token <agent-uuid> # Delete agent lox agents delete <agent-uuid> --yes
lox jobs
Manage scheduled backup jobs.
# List all jobs lox jobs list # List jobs for a specific agent lox jobs list --agent <agent-uuid> # Create a backup job lox jobs create <agent-uuid> "Daily Backup" \ --job-type file \ --sources "/home,/var/www" \ --exclusions "*.log,*.tmp,node_modules" \ --schedule-cron "0 2 * * *" \ --retention-daily 7 \ --retention-weekly 4 \ --retention-monthly 12 # Get job details lox jobs get <job-uuid> # Run job immediately lox jobs run <job-uuid> lox jobs run <job-uuid> --backup-type full # List job backups lox jobs backups <job-uuid> # Enable/disable job lox jobs enable <job-uuid> lox jobs disable <job-uuid> # Update job lox jobs update <job-uuid> \ --name "New Name" \ --schedule-cron "0 3 * * *" # Delete job and all its backups lox jobs delete <job-uuid> --yes
lox machine-backups
Manage machine backup restore points.
# List machine backups lox machine-backups list lox machine-backups list --status completed --limit 50 # Get backup details lox machine-backups get <backup-uuid> # Restore backup to original location lox machine-backups restore <backup-uuid> # Restore to alternate location lox machine-backups restore <backup-uuid> \ --target-type alternate \ --target-agent <other-agent-uuid> \ --target-path /restore/path # Selective restore lox machine-backups restore <backup-uuid> \ --restore-type selective \ --selected-items "/home/user/documents,/var/www" # Delete backup lox machine-backups delete <backup-uuid> --yes
lox config
Manage CLI configuration.
# Set configuration value lox config set api_key your-api-key lox config set default_retention_days 90 # Get configuration value lox config get api_key # Show all configuration lox config show # Reset configuration lox config reset
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Authentication error (invalid API key) |
| 3 | Not found (backup doesn't exist) |
| 4 | Quota exceeded |
| 5 | Timeout |
| 6 | File not found |
Scripting Examples
Daily Database Backup
#!/bin/bash # daily-backup.sh - Daily database backup to LOX set -e TIMESTAMP=$(date +%Y%m%d_%H%M%S) BACKUP_FILE="/tmp/db_$TIMESTAMP.sql.gz" # Create database dump mysqldump -u root --all-databases | gzip > "$BACKUP_FILE" # Upload to LOX lox backup upload "$BACKUP_FILE" \ --name "mysql-all-$TIMESTAMP" \ --tags "mysql,production,automated,daily" \ --retention 30 \ --wait \ --quiet # Cleanup rm -f "$BACKUP_FILE" echo "Backup completed: mysql-all-$TIMESTAMP"
Cron Setup
# Edit crontab crontab -e # Add daily backup at 2 AM 0 2 * * * /path/to/daily-backup.sh >> /var/log/lox-backup.log 2>&1 # Add weekly full backup at 3 AM on Sundays 0 3 * * 0 /path/to/weekly-backup.sh >> /var/log/lox-backup.log 2>&1
Backup with Retention Cleanup
#!/bin/bash # backup-with-cleanup.sh set -e # Upload new backup BACKUP_UUID=$(lox backup upload backup.tar.gz \ --name "app-backup-$(date +%Y%m%d)" \ --tags "app,production" \ --wait \ --json | jq -r '.uuid') echo "Created backup: $BACKUP_UUID" # Delete backups older than 30 days (by listing and filtering) OLD_BACKUPS=$(lox backup list \ --tags "app,production" \ --json | jq -r '.[] | select(.expires_at < now) | .uuid') for uuid in $OLD_BACKUPS; do echo "Deleting old backup: $uuid" lox backup delete "$uuid" --yes done
Check Quota Before Backup
#!/bin/bash
# safe-backup.sh - Check quota before uploading
set -e
BACKUP_FILE=$1
REQUIRED_SIZE=$(stat -f%z "$BACKUP_FILE" 2>/dev/null || stat -c%s "$BACKUP_FILE")
# Get current quota
QUOTA_INFO=$(lox tenant quota --json)
USED=$(echo "$QUOTA_INFO" | jq '.used_bytes')
QUOTA=$(echo "$QUOTA_INFO" | jq '.quota_bytes')
UNLIMITED=$(echo "$QUOTA_INFO" | jq '.unlimited')
if [ "$UNLIMITED" = "false" ]; then
AVAILABLE=$((QUOTA - USED))
if [ "$REQUIRED_SIZE" -gt "$AVAILABLE" ]; then
echo "ERROR: Not enough storage space"
echo "Required: $REQUIRED_SIZE bytes"
echo "Available: $AVAILABLE bytes"
exit 4
fi
fi
# Proceed with backup
lox backup upload "$BACKUP_FILE" --waitGlobal Options
| Option | Description |
|---|---|
| --api-key | Override API key for this command |
| --api-url | Override API URL for this command |
| --verbose, -v | Verbose output |
| --quiet, -q | Minimal output |
| --json | Output as JSON |
| --help, -h | Show help message |
| --version | Show version |