Skip to content

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 n Keep the n last (most recent) snapshots.

  • --keep-hourly n For the last n hours which have one or more snapshots, keep only the most recent one for each hour.

  • --keep-daily n For the last n days which have one or more snapshots, keep only the most recent one for each day.

  • --keep-weekly n For the last n weeks which have one or more snapshots, keep only the most recent one for each week.

  • --keep-monthly n For the last n months which have one or more snapshots, keep only the most recent one for each month.

  • --keep-yearly n For 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:

  1. Look at days that have snapshots and keep the newest snapshot for each of the last 7 days that have any snapshots
  2. Look at weeks that have snapshots and keep the newest snapshot for each of the last 5 weeks that have any snapshots