This commit is contained in:
2026-02-15 13:13:11 +01:00
parent 8b592db3dd
commit 2a5221c29a
8 changed files with 243 additions and 35 deletions

View File

@@ -98,7 +98,35 @@ func main() {
os.Exit(1)
}
if err := client.RestoreSnapshot(snapshot, targetDataset, force); err != nil {
if err := client.RestoreSnapshot(snapshot, targetDataset, force, snapshots); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
case "mount":
// Mount a restored dataset to access files
if len(os.Args) < 3 {
fmt.Println("Usage: zfs-restore mount <dataset> [mountpoint]")
fmt.Println("\nExamples:")
fmt.Println(" zfs-restore mount tank/restored /mnt/recover")
fmt.Println(" zfs-restore mount tank/restored # interactive")
os.Exit(1)
}
dataset := os.Args[2]
mountpoint := ""
if len(os.Args) > 3 {
mountpoint = os.Args[3]
} else {
fmt.Printf("Mountpoint [/mnt/recover]: ")
fmt.Scanln(&mountpoint)
if mountpoint == "" {
mountpoint = "/mnt/recover"
}
}
if err := client.MountDataset(dataset, mountpoint); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
@@ -119,11 +147,13 @@ func printUsage() {
fmt.Println("\nCommands:")
fmt.Println(" list - List available snapshots")
fmt.Println(" restore <#|latest> <dataset> [--force] - Restore snapshot to ZFS")
fmt.Println(" mount <dataset> [mountpoint] - Mount dataset to recover files")
fmt.Println(" help - Show this help message")
fmt.Println("\nQuick Examples:")
fmt.Println(" zfs-restore list - See available backups")
fmt.Println(" zfs-restore restore latest tank/data - Restore most recent backup")
fmt.Println(" zfs-restore restore 1 tank/restored - Restore snapshot #1")
fmt.Println(" zfs-restore mount tank/restored /mnt - Mount to recover files")
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)")