Debian Codegraph @

examples/create_snapshot/create_snapshot.go

raw symbols SCIP
1 // Copyright © 2013, 2014, The Go-LXC Authors. All rights reserved.
2 // Use of this source code is governed by a LGPLv2.1
3 // license that can be found in the LICENSE file.
4
5 //go:build linux && cgo
6 // +build linux,cgo
7
8 package main
9
10 import (
11 "flag"
12 "log"
13
14 "github.com/lxc/go-lxc"
15 )
16
17 var (
18 lxcpath string
19 name string
20 )
21
22 func init() {
23 flag.StringVar(&lxcpath, "lxcpath", lxc.DefaultConfigPath(), "Use specified container path")
24 flag.StringVar(&name, "name", "rubik", "Name of the container")
25 flag.Parse()
26 }
27
28 func main() {
29 c, err := lxc.NewContainer(name, lxcpath)
30 if err != nil {
31 log.Fatalf("ERROR: %s\n", err.Error())
32 }
33 defer c.Release()
34
35 log.Printf("Snapshoting the container...\n")
36 if _, err := c.CreateSnapshot(); err != nil {
37 log.Fatalf("ERROR: %s\n", err.Error())
38 }
39 }