Skip to content

Commit 057f332

Browse files
committed
Add CheckBefore and CheckAfter to Copy to Check the Destination Repo
1 parent 583438b commit 057f332

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

config/profile.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ type CopySection struct {
351351
GenericSectionWithSchedule `mapstructure:",squash"`
352352
Initialize bool `mapstructure:"initialize" description:"Initialize the secondary repository if missing"`
353353
InitializeCopyChunkerParams maybe.Bool `mapstructure:"initialize-copy-chunker-params" default:"true" description:"Copy chunker parameters when initializing the secondary repository"`
354+
CheckBefore bool `mapstructure:"check-before" description:"Check the repository before starting the backup command"`
355+
CheckAfter bool `mapstructure:"check-after" description:"Check the repository after the backup command succeeded"`
354356
FromRepository ConfidentialValue `mapstructure:"from-repo" argument:"from-repo" description:"Destination repository to copy snapshots from"`
355357
FromRepositoryFile string `mapstructure:"from-repository-file" argument:"from-repository-file" description:"File from which to read the source repository location to copy snapshots from"`
356358
FromPasswordFile string `mapstructure:"from-password-file" argument:"from-password-file" description:"File to read the source repository password from"`

wrapper.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ func (r *resticWrapper) getCopyAction() func() error {
147147
_ = r.runInitializeCopy() // it's ok if the initialization returned an error
148148
}
149149

150+
// Check before
151+
if r.profile.Copy != nil && r.profile.Copy.CheckBefore {
152+
err = r.runCheck()
153+
if err != nil {
154+
return
155+
}
156+
}
157+
150158
// Retention before
151159
if r.profile.Retention != nil && r.profile.Retention.BeforeCopy.IsTrue() {
152160
err = r.runRetention()
@@ -169,6 +177,14 @@ func (r *resticWrapper) getCopyAction() func() error {
169177
}
170178
}
171179

180+
// Check after
181+
if r.profile.Copy != nil && r.profile.Copy.CheckAfter {
182+
err = r.runCheck()
183+
if err != nil {
184+
return
185+
}
186+
}
187+
172188
return
173189
}
174190
}

0 commit comments

Comments
 (0)