{snapshot,backup}: Write machine-readable report

This commit is contained in:
Tom Wiesing 2023-03-19 17:38:36 +01:00
parent c79dcc6b90
commit b6d3575ee9
No known key found for this signature in database
6 changed files with 196 additions and 44 deletions

View file

@ -14,6 +14,9 @@ type snapshot struct {
Keepalive bool `short:"k" long:"keepalive" description:"keep instance running while taking a backup. might lead to inconsistent state"`
StagingOnly bool `short:"s" long:"staging-only" description:"do not package into a snapshot archive, but only create a staging directory"`
Parts []string `short:"p" long:"parts" description:"parts to include in snapshots. defaults to all parts, use l to list all available parts"`
List bool `short:"l" long:"list-parts" description:"list available parts"`
Positionals struct {
Slug string `positional-arg-name:"SLUG" required:"1-1" description:"slug of instance to take a snapshot of"`
Dest string "positional-arg-name:\"DEST\" description:\"destination path to write snapshot archive to. defaults to the `snapshots/archives/` directory\""
@ -43,6 +46,14 @@ var errSnapshotWissKI = exit.Error{
func (sn snapshot) Run(context wisski_distillery.Context) error {
dis := context.Environment
// list available parts
if sn.List {
for _, part := range dis.Exporter().Parts() {
context.Println(part)
}
return nil
}
// find the instance!
instance, err := dis.Instances().WissKI(context.Context, sn.Positionals.Slug)
if err != nil {
@ -54,6 +65,9 @@ func (sn snapshot) Run(context wisski_distillery.Context) error {
Dest: sn.Positionals.Dest,
StagingOnly: sn.StagingOnly,
SnapshotDescription: exporter.SnapshotDescription{
Parts: sn.Parts,
},
Instance: instance,
})