Skip to content

Commit

Permalink
Add simple verification command to test if the backup is readable
Browse files Browse the repository at this point in the history
  • Loading branch information
xeals committed Aug 2, 2018
1 parent 29929d1 commit 5b3bce7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cmd/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cmd

import (
"io/ioutil"
"log"
"os"

"github.com/pkg/errors"
"github.com/urfave/cli"
)

// Check fulfils the `format` subcommand.
var Check = cli.Command{
Name: "check",
Usage: "Verify that a backup is readable",
UsageText: "Attempts to decrypt the provided backup and do nothing with it except verify that it's readable\n from start to finish. Enables verbose logging by default.",
CustomHelpTemplate: SubcommandHelp,
Flags: []cli.Flag{
cli.StringFlag{
Name: "password, p",
Usage: "use `PASS` as password for backup file",
},
cli.StringFlag{
Name: "pwdfile, P",
Usage: "read password from `FILE`",
},
},
Action: func(c *cli.Context) error {
bf, err := setup(c)
if err != nil {
return err
}

log.SetOutput(os.Stderr)

if err := Raw(bf, ioutil.Discard); err != nil {
return errors.Wrap(err, "Encountered error while checking")
}

log.Println("Backup looks okay from here.")
return nil
},
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func main() {
cmd.Format,
cmd.Analyse,
cmd.Extract,
cmd.Check,
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Expand Down

0 comments on commit 5b3bce7

Please sign in to comment.