Understanding Restic Retention Flags
Restic provides several flags for the forget command to control which snapshots should be kept in your repository. Below are the precise definitions of each retention flag.
Core Retention Flags
Time-Based Retention
-
--keep-last nKeep the n last (most recent) snapshots. -
--keep-hourly nFor the last n hours which have one or more snapshots, keep only the most recent one for each hour. -
--keep-daily nFor the last n days which have one or more snapshots, keep only the most recent one for each day. -
--keep-weekly nFor the last n weeks which have one or more snapshots, keep only the most recent one for each week. -
--keep-monthly nFor the last n months which have one or more snapshots, keep only the most recent one for each month. -
--keep-yearly nFor the last n years which have one or more snapshots, keep only the most recent one for each year.
Example Scenario
Basic Retention Example
$ restic forget --keep-daily 7 --keep-weekly 5
This will:
- Look at days that have snapshots and keep the newest snapshot for each of the last 7 days that have any snapshots
- Look at weeks that have snapshots and keep the newest snapshot for each of the last 5 weeks that have any snapshots