Skip to content

Commit 29557af

Browse files
committed
fix: actually PRUNE backups when deleting them
1 parent 0f9af10 commit 29557af

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/server/backup/backup_rustic.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,21 @@ func (r *RusticBackup) Remove() error {
219219
defer cancel()
220220
defer r.cleanup()
221221

222-
cmd := r.buildRusticCommandWithContext(ctx, "forget", r.snapshotID)
223-
if err := cmd.Run(); err != nil {
224-
return errors.Wrap(err, "rustic: failed to remove snapshot")
222+
r.log().WithField("snapshot_id", r.snapshotID).Info("removing rustic snapshot with pruning")
223+
224+
cmd := r.buildRusticCommandWithContext(ctx, "forget", "--prune", r.snapshotID)
225+
output, err := cmd.CombinedOutput()
226+
if err != nil {
227+
r.log().WithField("output", string(output)).
228+
WithField("snapshot_id", r.snapshotID).
229+
Error("rustic snapshot removal failed")
230+
return errors.Wrapf(err, "rustic: failed to remove snapshot: %s", string(output))
225231
}
226232

233+
r.log().WithField("output", string(output)).
234+
WithField("snapshot_id", r.snapshotID).
235+
Info("rustic snapshot removed successfully")
236+
227237
return nil
228238
}
229239

0 commit comments

Comments
 (0)