-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple verification command to test if the backup is readable
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters