// Command zfs-client is a simple CLI tool for creating and sending ZFS snapshots. package main import ( "fmt" "os" "git.ma-al.com/goc_marek/zfs/internal/client" ) func main() { if len(os.Args) < 2 { printUsage() os.Exit(1) } // Load configuration from environment and .env file config := client.LoadConfig() c := client.New(config) command := os.Args[1] switch command { case "snap", "snapshot": // Create snapshot and send to server (auto full/incremental) fmt.Println("=== Creating and sending snapshot ===\n") snapshot, err := c.CreateAndSend() if err != nil { fmt.Printf("Error: %v\n", err) os.Exit(1) } if snapshot.FullBackup { fmt.Println("\n✓ Full backup completed!") } else { fmt.Println("\n✓ Incremental backup completed!") } case "status": // Check server connection and quota if err := c.GetStatus(); err != nil { fmt.Printf("Error: %v\n", err) os.Exit(1) } case "help", "-h", "--help": printUsage() default: fmt.Printf("Unknown command: %s\n", command) printUsage() os.Exit(1) } } func printUsage() { fmt.Println("ZFS Snapshot Backup Client - Simple Version") fmt.Println("\nUsage: zfs-client [command]") fmt.Println("\nCommands:") fmt.Println(" snap - Create snapshot and send to server (auto full/incremental)") fmt.Println(" status - Check server connection and quota") fmt.Println(" help - Show this help message") fmt.Println("\nEnvironment Variables (can be set in .env file):") fmt.Println(" CLIENT_ID - Client identifier (default: client1)") fmt.Println(" API_KEY - API key for authentication (default: secret123)") fmt.Println(" SERVER_URL - Backup server URL (default: http://localhost:8080)") fmt.Println(" LOCAL_DATASET - ZFS dataset to backup (default: tank/data)") fmt.Println(" COMPRESS - Enable LZ4 compression (default: true)") fmt.Println("\nS3 Configuration (for direct S3 uploads):") fmt.Println(" S3_ENDPOINT - S3 endpoint URL (e.g., https://s3.amazonaws.com)") fmt.Println(" S3_REGION - AWS region (default: us-east-1)") fmt.Println(" S3_BUCKET - S3 bucket name (default: zfs-backups)") fmt.Println(" S3_ACCESS_KEY - AWS access key") fmt.Println(" S3_SECRET_KEY - AWS secret key") fmt.Println("\nExamples:") fmt.Println(" zfs-client snap") fmt.Println(" zfs-client status") }