mirror of https://github.com/restic/restic.git
Merge pull request #15 from NetApp-Polaris/ASTRACTL-31217-add-back-delete-repo
adds back option to delete empty repo
This commit is contained in:
commit
08b8450b18
|
@ -248,7 +248,29 @@ func runForget(ctx context.Context, opts ForgetOptions, gopts GlobalOptions, arg
|
|||
}
|
||||
}
|
||||
pruneOptions.DryRun = opts.DryRun
|
||||
return runPruneWithRepo(ctx, pruneOptions, gopts, repo, removeSnIDs)
|
||||
err = runPruneWithRepo(ctx, pruneOptions, gopts, repo, removeSnIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if opts.deleteEmptyRepo {
|
||||
snapshotCount := 0
|
||||
for range FindFilteredSnapshots(ctx, repo.Backend(), repo, opts.Hosts, opts.Tags, opts.Paths, []string{}) {
|
||||
snapshotCount++
|
||||
}
|
||||
|
||||
if opts.DryRun && snapshotCount == 1 {
|
||||
if !gopts.JSON {
|
||||
Printf("Would have removed the repo\n")
|
||||
}
|
||||
} else if snapshotCount == 0 {
|
||||
Printf("No more snapshots left, removing the repo\n")
|
||||
err = repo.Delete(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue