About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
Deleting a backup from a deduplicated store removes the backup's list of blocks. It does not remove the blocks. Space comes back only when a second, separate clean-up pass runs, and only for blocks that no remaining backup still uses. If you deleted backups and df did not move, the usual cause is that the clean-up pass never ran, ran with a tolerance that left the space in place, or could not run because of a lock or a permission.
Do not delete more backups to "make it work". Work out which stage you are at first, using read-only checks.
What the symptom means
In a store that keeps each block once, many backups share the same blocks. A backup is a list of references. Deleting a backup deletes its list. A block is garbage only when the last list that mentioned it is gone, and finding that out is a separate job.
The two tools covered here document exactly this split.
restic. The restic documentation says that "two commands need to be called in sequence: forget to remove snapshots, and prune to remove the remaining data that was referenced only by the removed snapshots." After forget alone, "the data that was referenced by files in this snapshot is still stored in the repository." The design reference adds that all files in a repository "are only written once and never modified afterwards" and that "only the prune operation removes data from the repository."
Borg. Since Borg 1.2.0, "repository space is not freed immediately when deleting / pruning archives". Both the borg delete and borg prune pages say space "is not freed until you run borg compact", and the compact page says that "only compaction will really free repository space." The repository's data files are described as strictly append-only: a delete adds a DELETE entry, and compaction later rewrites the files that hold mostly dead entries.
Windows Data Deduplication has the same two-step shape, with a Garbage Collection job as the clean-up pass. It has its own article on Garbage Collection, so it is not explained here.
Why the freed amount is small
The second half of the symptom is that even a successful clean-up frees less than the deleted backups appear to weigh. Borg documents this directly: "This archive / deduplicated size = amount of data stored ONLY for this archive = unique chunks of this archive." Its own sample shows an archive of 12.53 GB original size whose deduplicated size is 1.62 kB. Deleting that archive frees about 1.62 kB.
Two tolerances that keep space on purpose
- restic
prunehas--max-unused, default 5%. It "allow[s] unused data up to the specified limit within the repository", so partly used pack files can be kept rather than rewritten. Passing 0 "minimize[s] the space used" at the cost of more repacking. - Borg
compacthas--threshold, default 10%. A segment "is compacted if the amount of saved space is above the percentage value given by the --threshold option."
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Only the delete step ran | Snapshot or archive list is shorter; disk use unchanged | restic: forget run without --prune and no separate prune. Borg: no borg compact in any job |
| Deleted backups were mostly shared data | A little space returns, far less than the backups' size | Borg info deduplicated size for the archive; restic dry-run prune totals |
| Clean-up ran but tolerance left space in place | A small, steady amount stays unused | restic "unused size after prune" line; Borg threshold of 10% |
| Clean-up cannot get the lock | Prune or compact fails or never starts; backups still run | restic exit status 11; Borg lock timeout. See the lock topics named under Fix |
| Store is append-only | borg compact finishes without error and frees nothing |
Repository config has append_only set, or the key forces borg serve --append-only |
| Space is held outside the backup tool | Tool reports the repository smaller than the storage does | Versioned bucket, retention lock or storage-side snapshots; see below |
Prove the cause before changing anything
These checks do not change the repository. Run them from the machine that runs clean-up.
restic.
restic snapshots
restic prune --dry-run --no-lock
--dry-run is documented as "do not modify the repository, just print what would be done". In the v0.19.1 source, prune takes the exclusive lock even with --dry-run, unless you add --no-lock, which the source accepts only together with --dry-run. The documentation shows the lines prune prints: to repack, this removes, to delete, total prune, remaining and unused size after prune. A large total prune means the space is waiting for the clean-up pass. A total prune near zero with many snapshots removed means the deleted snapshots shared their blocks with kept ones.
Borg.
borg info /srv/backup/repo
borg prune -v --list --dry-run --keep-daily=7 --keep-weekly=4 /srv/backup/repo
borg info on the repository shows "All archives" deduplicated size, described as "all chunks in the repository". Compare it with the size the storage reports for the repository directory. If the directory is much larger, the difference is dead data that compaction can rewrite away; the documentation states that deletion leaves data in place until compaction, but does not describe this comparison, so treat it as a rule of thumb. borg compact --dry-run is not a preview: in the 1.4.5 source it does nothing. The estimate of freed space comes only from a real run with --verbose. --stats is ignored, with a warning, when --dry-run is given.
Check for append-only. Borg's repository layout puts settings in a file called config; read it for append_only. Also read the authorized_keys line of the account you back up with: Borg documents command="borg serve --append-only ..." for backup clients. With append-only, "there will be no warning or error, but no compaction will happen."
Example (illustrative): fs01 backs up about 800 GiB of data into a restic repository at /srv/backup/restic-repo. The retention policy is cut from 90 daily snapshots to 30, so forget removes 60 snapshots. Those 60 snapshots each restore about 800 GiB, so 60 × 800 = 48,000 GiB of logical references disappeared. The disk usage stays at 1,100 GiB because only forget ran. restic prune --dry-run --no-lock then prints a total prune of about 140 GiB and a remaining of 960 GiB, with unused size after prune of 40 GiB. Real space freed is 140 GiB, less than 0.3% of the logical figure (140 ÷ 48,000 = 0.29%). The 40 GiB left unused is 40 ÷ 960 = 4.2% of what remains, inside the default 5% tolerance (5% of 960 GiB is 48 GiB). Running with --max-unused 0 would recover that 40 GiB as well, at the cost of more repacking.
Fix
Cause 1 and 3: run the clean-up pass
restic. Run restic prune in a window with no backups, because "during a prune operation, the repository is locked and backups cannot be completed." forget --prune does both steps in one command.
Disruptive step: restic prune rewrites partly used pack files and deletes unused ones. It needs scratch space because "prune first stores all repacked files and deletes the obsolete files at the end". Removed data cannot be restored afterwards. To back out, restore from another copy; there is no undo inside the repository. If the disk is full, the documented first attempt is restic prune --max-repack-size 0, which needs several snapshots to have been removed with forget beforehand. The documentation also lists --unsafe-recover-no-free-space as a last resort and warns it can leave the repository temporarily unusable. Do not use it without a copy.
Borg. Run borg compact /srv/backup/repo. Add -v to log how much was freed.
Disruptive step: borg compact rewrites segment files and takes the exclusive lock. After it runs, the documentation says you can no longer roll the repository back to a state before the deletion: rollback works "provided that borg compact has not been run since then." Make sure the deletions are what you intended. There is no way back after compaction.
Cause 2: shared data
Nothing is wrong. The space is not free because kept backups use those blocks. If you need space now, the lever is shorter retention, not repeating the clean-up.
Cause 4: the lock
For restic exit status 11, follow "restic: 'repository is already locked': stale locks, running jobs and when to unlock". For Borg, follow "Borg 'Failed to create/acquire the lock': stale locks, running jobs and when break-lock is safe". Stop jobs from overlapping. Do not break a lock until you have proved no job is running.
Cause 5: append-only
Compaction and pruning belong with a separate administrative credential. The restic documentation says that "to remove snapshots and recover the corresponding disk space, the forget and prune commands require full read, write and delete access to the repository", and recommends "a separate and well-secured client" for it. Borg shows two authorized_keys entries, one with --append-only for clients and one without it, described as the "key used for backup management". Run borg compact from the second.
Cause 6: space held outside the tool
- Versioned S3 bucket. Amazon states that when you delete an object in a versioned bucket, "Amazon S3 inserts a delete marker instead of removing the object permanently", and that "each version of an object is the entire object; it is not just a diff". Deleting through the backup tool leaves older versions in place.
- Retention lock. An Object Lock retention period "specifies a fixed period of time during which an object version remains locked", and a legal hold has no expiry and "remains in place until you explicitly remove it". Locked data cannot be freed early.
- Windows deduplicated volume. Space returns after the Garbage Collection job; see the Windows article.
Confirm the fix
- restic:
prunefinishes, and its closing statistics show the expectedunused size after prune. The documentation advises runningrestic checkafter pruning. - Borg:
borg compact -vreports freed space, and the storage's own figure for the repository directory falls towards theborg info"All archives" figure. - The next scheduled backup completes. A clean-up that frees space but leaves backups broken is not a fix.
What to watch afterwards
- Run clean-up on a schedule that does not overlap backups. restic has
--retry-lock("default: no retries"); Borg has--lock-wait SECONDS(default 1). - Keep a record of repository size next to retention changes, so a retention change that frees nothing is noticed within a cycle.
- Alert when no
compactorprunehas completed for longer than your longest retention gap.
Read next
Related articles you may want next.
- Backup & RecoveryWindows Data Deduplication: deleted files but the volume is still fullDeleted files on a deduplicated Windows volume but free space did not rise? Check Garbage Collection with Get-DedupStatus, then decide on a full run.Read article
- Backup & RecoveryBorg 'Failed to create/acquire the lock': stale locks, running jobs and when break-lock is safeBorg says Failed to create/acquire the lock. Tell a running job, a hung borg serve and a stale lock apart before you run borg break-lock.Read article
- CloudS3 Object Lock and versioning: designing backups that an admin cannot deleteWhat versioning, MFA delete, legal holds, governance and compliance mode each stop, who can undo them, and a safe build order for a backup bucket.Read article
Risks and limits
- These commands have not been run or lab-tested. They are taken from the vendor documentation and source listed below.
- Borg 2.x has a different repository format and is not covered. The "rule of thumb" comparison of
borg infowith directory size is reasoning, not a vendor statement. - The size of the effect depends entirely on how much data is shared. The example uses made-up figures.
- The restic lock behaviour of
--dry-runis taken from the v0.19.1 source and may differ in other versions. - Storage-side snapshots, replicated copies and other holders outside the backup tool are not described by these vendors.
Sources
- restic: Removing backup snapshots — restic documentation, no date displayed
- restic: Design, repository format — restic documentation, no date displayed
- restic manual: global options — restic documentation, no date displayed
- restic-prune(1) — restic project
- restic v0.19.1 source: cmd_prune.go and lock.go — restic project
- restic changelog — latest entry 0.19.1, 2026-07-05
- Borg: borg delete, borg prune, borg compact, borg info — Borg 1.4.5 documentation
- Borg: additional notes (separate compaction, append-only, rollback) — Borg 1.4.5 documentation
- Borg: data structures and file formats — Borg 1.4.5 documentation
- Borg 1.4.5 source, archiver.py — Borg project
- Amazon S3: Retaining multiple versions of objects — AWS documentation, no date displayed
- Amazon S3: Object Lock — AWS documentation, no date displayed
- Microsoft Learn: Understanding Data Deduplication — last updated 2022-02-18
This article was originally published on .