ZFS Snapshot release before updating
This commit is contained in:
parent
d0646c51b3
commit
fb4010378f
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
gVersion = "0.42c"
|
||||
gVersion = "0.42d"
|
||||
|
||||
// TODO : Get from $jail_zpool/defaults.json
|
||||
MIN_DYN_DEVFS_RULESET = 1000
|
||||
|
@ -66,7 +66,7 @@ func UpdateJail(args []string) {
|
||||
// get datastore mountpoing from datastore name
|
||||
ds, err := getDatastoreFromArray(gUpdateReleaseDS, gDatastores)
|
||||
if err != nil {
|
||||
fmt.Printf("Error gettting datastore %s: %v\n", gUpdateReleaseDS, err)
|
||||
fmt.Printf("Error getting datastore %s: %v\n", gUpdateReleaseDS, err)
|
||||
return
|
||||
}
|
||||
rp := fmt.Sprintf("%s/releases/%s/root", ds.Mountpoint, gUpdateRelease)
|
||||
@ -77,6 +77,23 @@ func UpdateJail(args []string) {
|
||||
return
|
||||
}
|
||||
fakeJail.Config.Release = v
|
||||
|
||||
// Snapshot before updating
|
||||
dt := time.Now()
|
||||
curDate := fmt.Sprintf("%s", dt.Format("2006-01-02_15-04-05"))
|
||||
snapshotName := fmt.Sprintf("gocage_update_%s_%s", v, curDate)
|
||||
err = zfsSnapshot(fmt.Sprintf("%s/releases/%s", ds.ZFSDataset, fakeJail.Config.Release), snapshotName)
|
||||
if err != nil {
|
||||
fmt.Printf("Error snapshoting release %s: %v\n", gUpdateRelease, err)
|
||||
return
|
||||
}
|
||||
err = zfsSnapshot(fmt.Sprintf("%s/releases/%s/root", ds.ZFSDataset, fakeJail.Config.Release), snapshotName)
|
||||
if err != nil {
|
||||
fmt.Printf("Error snapshoting release %s: %v\n", gUpdateRelease, err)
|
||||
} else {
|
||||
fmt.Printf("Release %s was snapshoted with success: %s\n", gUpdateRelease, snapshotName)
|
||||
}
|
||||
|
||||
if err = updateJail(&fakeJail, false); err != nil {
|
||||
fmt.Printf("Error updating release %s: %v\n", gUpdateRelease, err)
|
||||
}
|
||||
@ -101,7 +118,7 @@ func UpdateJail(args []string) {
|
||||
// Set snapshot name
|
||||
dt := time.Now()
|
||||
curDate := fmt.Sprintf("%s", dt.Format("2006-01-02_15-04-05"))
|
||||
gSnapshotName = fmt.Sprintf("goc_update_%s_%s", cj.Config.Release, curDate)
|
||||
gSnapshotName = fmt.Sprintf("gocage_update_%s_%s", cj.Config.Release, curDate)
|
||||
err := createJailSnapshot(*cj)
|
||||
if err != nil {
|
||||
fmt.Printf(" > Snapshot jail %s: ERROR: %s\n", cj.Name, err.Error())
|
||||
|
Loading…
Reference in New Issue
Block a user