Fix migrate: use datastore.ZFSDataset for replication to dest

This commit is contained in:
yo 2022-06-18 16:24:53 +02:00
parent e84c43c759
commit 2151034a02

View File

@ -6,8 +6,6 @@ import (
"bufio"
"errors"
"strings"
"github.com/spf13/viper"
)
const (
@ -20,6 +18,7 @@ const (
*******************************************************************************/
func MigrateJail(args []string) {
var jailNames []string
var destDS Datastore
if len(args) > 0 {
for _, a := range args {
@ -29,16 +28,12 @@ func MigrateJail(args []string) {
for _, jn := range jailNames {
// Check if destination datastore exist
/*cmd := fmt.Sprintf("zfs list %s/iocage/jails", gMigrateDestDatastore)
out, err := executeCommand(cmd)
if err != nil {
fmt.Printf("Error executing command %s: %v; command returned: %s\n", cmd, err, out)
return
}*/
found := false
for _, ds := range viper.GetStringSlice("datastore") {
if strings.EqualFold(gMigrateDestDatastore, ds) {
for _, ds := range gDatastores {
if strings.EqualFold(gMigrateDestDatastore, ds.Name) {
found = true
destDS = ds
break
}
}
if false == found {
@ -95,17 +90,15 @@ func MigrateJail(args []string) {
return
}
fmt.Printf("Done\n")
// FIXME: Must use zfs dataset, not mountpoint stored in gMigrateDestDatastore
dsconfdest := strings.Join([]string{gMigrateDestDatastore, "iocage", "jails", jn}, "/")
dsconfdest := strings.Join([]string{destDS.ZFSDataset, "jails", jn}, "/")
fmt.Printf("Migrate jail config dataset to %s: ", dsconfdest)
if err := zfsCopy(fmt.Sprintf("%s@gocage_mig_init", dsconf), dsconfdest); err != nil {
fmt.Printf("Error: %v\n", err)
}
fmt.Printf("Done\n")
// FIXME: Must use zfs dataset, not mountpoint stored in gMigrateDestDatastore
dsdatadest := strings.Join([]string{gMigrateDestDatastore, "iocage", "jails", jn, "root"}, "/")
dsdatadest := strings.Join([]string{destDS.ZFSDataset, "jails", jn, "root"}, "/")
fmt.Printf("Migrate jail filesystem dataset to %s: ", dsdatadest)
if err := zfsCopy(fmt.Sprintf("%s@gocage_mig_init", dsdata), dsdatadest); err != nil {
fmt.Printf("Error: %v\n", err)