@@ -64,6 +64,7 @@ func main() {
6464 // All other commands need a config file
6565 fs := flag .NewFlagSet (cmd , flag .ExitOnError )
6666 configPath := fs .String ("config" , config .DefaultConfigPath (), "path to config file" )
67+ debug := fs .Bool ("debug" , false , "print full commands with credentials (for manual testing)" )
6768 fs .Parse (os .Args [2 :])
6869
6970 cfg , err := config .Load (* configPath )
@@ -79,11 +80,11 @@ func main() {
7980
8081 switch cmd {
8182 case "backup" :
82- runBackup (ctx , cfg , log )
83+ runBackup (ctx , cfg , log , * debug )
8384 case "check" :
84- runCheck (ctx , cfg , log )
85+ runCheck (ctx , cfg , log , * debug )
8586 case "status" :
86- runStatus (ctx , cfg , log )
87+ runStatus (ctx , cfg , log , * debug )
8788 case "install" :
8889 runInstall (cfg , log , * configPath )
8990 case "uninstall" :
@@ -95,7 +96,13 @@ func main() {
9596 }
9697}
9798
98- func runBackup (ctx context.Context , cfg * config.Config , log * logger.Logger ) {
99+ func newRunner (cfg * config.Config , log * logger.Logger , debug bool ) * restic.Runner {
100+ r := restic .NewRunner (cfg , log )
101+ r .Debug = debug
102+ return r
103+ }
104+
105+ func runBackup (ctx context.Context , cfg * config.Config , log * logger.Logger , debug bool ) {
99106 // Acquire process lock — auto-clears stale locks from dead processes
100107 lock , err := lockfile .New (0 )
101108 if err != nil {
@@ -109,14 +116,15 @@ func runBackup(ctx context.Context, cfg *config.Config, log *logger.Logger) {
109116 defer lock .Release ()
110117
111118 orch := backup .NewOrchestrator (cfg , log )
119+ orch .SetDebug (debug )
112120 if err := orch .Run (ctx ); err != nil {
113121 log .Error ("backup failed" , map [string ]any {"error" : err .Error ()})
114122 os .Exit (1 )
115123 }
116124}
117125
118- func runCheck (ctx context.Context , cfg * config.Config , log * logger.Logger ) {
119- runner := restic . NewRunner (cfg , log )
126+ func runCheck (ctx context.Context , cfg * config.Config , log * logger.Logger , debug bool ) {
127+ runner := newRunner (cfg , log , debug )
120128
121129 log .Info ("running full integrity check with data read" )
122130 result , err := runner .Check (ctx , 100 ) // full read
@@ -138,8 +146,8 @@ func runCheck(ctx context.Context, cfg *config.Config, log *logger.Logger) {
138146 log .Info ("integrity check passed — all data verified" )
139147}
140148
141- func runStatus (ctx context.Context , cfg * config.Config , log * logger.Logger ) {
142- runner := restic . NewRunner (cfg , log )
149+ func runStatus (ctx context.Context , cfg * config.Config , log * logger.Logger , debug bool ) {
150+ runner := newRunner (cfg , log , debug )
143151
144152 fmt .Println ("=== Repository Snapshots ===" )
145153 result , err := runner .Snapshots (ctx )
@@ -202,6 +210,7 @@ Commands:
202210
203211Flags:
204212 --config Path to config JSON file (default: restic-sentry.json next to binary)
213+ --debug Print full restic commands with credentials visible (for manual testing)
205214
206215Examples:
207216 restic-sentry install-restic # download restic
0 commit comments