-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
137 lines (134 loc) · 3.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package main
import (
"fmt"
"os"
"github.com/BTrDB/smartgridstore/tools"
"github.com/BTrDB/smartgridstore/tools/backuptool/core"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "btrdb-backup"
app.Usage = "create a backup of a BTrDB cluster"
app.Version = fmt.Sprintf("%d.%d.%d", tools.VersionMajor, tools.VersionMinor, tools.VersionPatch)
app.Commands = []cli.Command{
{
Name: "create",
Usage: "create a new backup ",
Flags: []cli.Flag{
cli.StringFlag{
Name: "cephconf",
Value: "/etc/ceph/ceph.conf",
Usage: "the location of ceph.conf",
},
cli.StringFlag{
Name: "outputdir",
Value: "backup.dir",
Usage: "the output directory",
},
cli.StringSliceFlag{
Name: "skip-pool",
Usage: "the ceph pools to skip",
},
cli.StringSliceFlag{
Name: "include-pool",
Usage: "the ceph pools to include (default: all)",
},
cli.StringFlag{
Name: "etcd",
Value: "127.0.0.1:2379",
Usage: "the address of the etcd server",
},
cli.StringFlag{
Name: "incremental-over",
Usage: "perform the backup as incremental over the given backup",
},
cli.BoolFlag{
Name: "skip-ceph",
Usage: "just back up etcd",
},
cli.BoolFlag{
Name: "skip-etcd",
Usage: "just back up ceph",
},
},
Action: cli.ActionFunc(core.Create),
},
{
Name: "inspect",
Usage: "check the integrity of some backup files",
Action: cli.ActionFunc(core.Inspect),
Flags: []cli.Flag{
cli.StringFlag{
Name: "outputdir",
Value: "backup.dir",
Usage: "the output directory containing the backup",
},
},
},
{
Name: "clear",
Usage: "delete everything in the restore target",
Action: cli.ActionFunc(core.Clear),
Flags: []cli.Flag{
cli.StringFlag{
Name: "cephconf",
Value: "/etc/ceph/ceph.conf",
Usage: "the location of ceph.conf",
},
cli.StringSliceFlag{
Name: "include-pool",
Usage: "the ceph pools to include (default: none)",
},
cli.StringFlag{
Name: "etcd",
Value: "127.0.0.1:2379",
Usage: "the address of the etcd server",
},
cli.BoolFlag{
Name: "skip-ceph",
Usage: "just clear etcd",
},
cli.BoolFlag{
Name: "skip-etcd",
Usage: "just clear ceph",
},
},
},
{
Name: "restore",
Usage: "restore a backup to a fresh cluster",
Action: cli.ActionFunc(core.Restore),
Flags: []cli.Flag{
cli.StringFlag{
Name: "cephconf",
Value: "/etc/ceph/ceph.conf",
Usage: "the location of ceph.conf",
},
cli.StringFlag{
Name: "outputdir",
Value: "backup.dir",
Usage: "the output directory containing the backup",
},
cli.StringSliceFlag{
Name: "restore-pool",
Usage: "<backupname>:<restorename>",
},
cli.StringFlag{
Name: "etcd",
Value: "127.0.0.1:2379",
Usage: "the address of the etcd server",
},
cli.BoolFlag{
Name: "skip-ceph",
Usage: "just restore etcd",
},
cli.BoolFlag{
Name: "skip-etcd",
Usage: "just restore ceph",
},
},
},
}
app.Run(os.Args)
}