"gocage migrate jail -d destination_dataset" working for cold migrations

This commit is contained in:
yo
2022-06-05 14:09:55 +02:00
parent 57c8bba09b
commit fb3ee07585
2 changed files with 89 additions and 6 deletions

View File

@ -15,7 +15,7 @@ import (
)
const (
gVersion = "0.26a"
gVersion = "0.27c"
)
var (
@ -34,6 +34,8 @@ var (
gTimeZone string
gSnapshotName string
gMigrateDestPool string
rootCmd = &cobra.Command{
Use: "gocage",
Short: "GoCage is a FreeBSD Jail management tool",
@ -189,6 +191,28 @@ You can specify multiple jails.`,
DeleteJailSnapshot(args)
},
}
migrateCmd = &cobra.Command{
Use: "migrate",
Short: "Migrate jail to another zpool",
Run: func(cmd *cobra.Command, args []string) {
// Load inventory
ListJails(args, false)
MigrateJail(args)
WriteConfigToDisk(false)
},
}
migrateCleanCmd = &cobra.Command{
Use: "clean",
Short: "Clean previous aborted/in error jail migration",
Run: func(cmd *cobra.Command, args []string) {
// Load inventory
ListJails(args, false)
CleanMigrateMess(args)
},
}
)
// TODO : Init log level and log output
@ -216,6 +240,9 @@ func init() {
snapshotRollbackCmd.Flags().StringVarP(&gSnapshotName, "snapname", "n", "", "Name of the snapshot to rollback to")
snapshotRollbackCmd.MarkFlagRequired("snapname")
migrateCmd.Flags().StringVarP(&gMigrateDestPool, "destpool", "d", "", "Name of zfs destination pool for jail")
migrateCmd.MarkFlagRequired("destpool")
// Now declare commands
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(listCmd)
@ -225,10 +252,12 @@ func init() {
rootCmd.AddCommand(getCmd)
rootCmd.AddCommand(setCmd)
rootCmd.AddCommand(snapshotCmd)
rootCmd.AddCommand(migrateCmd)
snapshotCmd.AddCommand(snapshotListCmd)
snapshotCmd.AddCommand(snapshotCreateCmd)
snapshotCmd.AddCommand(snapshotDeleteCmd)
snapshotCmd.AddCommand(snapshotRollbackCmd)
migrateCmd.AddCommand(migrateCleanCmd)
// Get FreeBSD version
out, err := executeCommand("freebsd-version")