Remove old snapshots
Keep only the most recent snapshots and free the storage that older snapshots used.
Before you begin
- Create at least four snapshots. Run Back up files several times.
- Understand that removed snapshots cannot be restored.
Steps
-
Preview the result with a dry run. The dry run changes nothing:
bash restic forget --keep-last 3 --dry-run --repo /tmp/restic-demo-repo -
Review the list of snapshots that restic would keep and remove.
-
Run the command again without
--dry-run, and add--pruneto free the storage. Restic reports how many snapshots it removed, and the output ends withdone:bash restic forget --keep-last 3 --prune --repo /tmp/restic-demo-repo -
List the snapshots to confirm that only three remain:
bash restic snapshots --repo /tmp/restic-demo-repo
Forget and prune
The forget command removes snapshot records. The prune command deletes stored data that no snapshot uses anymore. The --prune flag runs both in one step.