@@ -16,6 +16,8 @@ import (
16
16
"strconv"
17
17
"github.com/pkg/errors"
18
18
"github.com/subutai-io/agent/config"
19
+ "time"
20
+ "fmt"
19
21
)
20
22
21
23
var zfsRootDataset string
@@ -83,7 +85,7 @@ func CreateDataset(dataset string) error {
83
85
// Lists snapshots for dataset
84
86
// Returns output of `zfs list -t snapshot -r {root}/{dataset}` command
85
87
func ListSnapshots (dataset string ) (string , error ) {
86
- out , err := exec .Execute ("zfs" , "list" , "-t" , "snapshot" , "-o" , "name,creation " , "-r" , path .Join (zfsRootDataset , dataset ))
88
+ out , err := exec .Execute ("zfs" , "list" , "-t" , "snapshot" , "-o" , "name,:created " , "-r" , path .Join (zfsRootDataset , dataset ))
87
89
if err != nil {
88
90
return "" , errors .Errorf ("Error listing snapshots for %s: %s %s" , dataset , out , err .Error ())
89
91
}
@@ -117,7 +119,7 @@ func RollbackToSnapshot(snapshot string, forceRollback bool) error {
117
119
// Creates snapshot
118
120
// e.g. CreateSnapshot("foo/rootfs@now")
119
121
func CreateSnapshot (snapshot string , recursive bool ) error {
120
- args := []string {"snapshot" }
122
+ args := []string {"snapshot" , "-o" , ":created=" + getTimestamp () }
121
123
if recursive {
122
124
args = append (args , "-r" )
123
125
}
@@ -273,3 +275,11 @@ func ConvertToBytes(input string) (int, error) {
273
275
res := float64 (multiplier ) * num
274
276
return int (res ), err
275
277
}
278
+
279
+ func getTimestamp () string {
280
+ t := time .Now ()
281
+ umillisec := t .Nanosecond () / 1000000
282
+ return fmt .Sprintf ("%d-%02d-%02dT%02d:%02d:%02d.%d" ,
283
+ t .Year (), t .Month (), t .Day (),
284
+ t .Hour (), t .Minute (), t .Second (), umillisec )
285
+ }
0 commit comments