How to Set Snapper Timeline Retention for Snapshot Backup on Linux

Snapper is a Linux utility to take backups on Linux.

It is especially helpful to create multiple snapshots of your filesystem. Once you take a snapshot, you can later use that snapshot to restore files.

If you are new to snapper, you should first install and configure snapper.

Once you configure snapshot, you can manually take snapshots.

Apart from the the manually taken snapshots, there are timeline triggered automatic snapshots which can be set to take hourly snapshots.

The following snapper output shows that there are automatic snapshot taken.

Notice the “cleanup” and “description” column where it says “timeline”.

# snapper -c snapconfig list
Type   | # | Pre # | Date                     | User | Cleanup  | Description                  | Userdata
-------+---+-------+--------------------------+------+----------+------------------------------+---------
single | 0 |       |                          | root |          | current                      |
single | 1 |       | Mon Feb 24 15:57:00 2014 | root |          | Snapshot taken on 02-24-0354 |
single | 2 |       | Mon Feb 24 16:27:48 2014 | root |          | Snapshot taken on 02-24-0427 |
single | 3 |       | Mon Feb 24 16:37:53 2014 | root |          | Snapshot taken on 02-24-0437 |
single | 4 |       | Mon Feb 24 16:38:17 2014 | root |          | Snapshot taken on 02-24-0440 |
single | 5 |       | Mon Feb 24 16:45:01 2014 | root | timeline | timeline                     |
single | 6 |       | Mon Feb 24 17:45:01 2014 | root | timeline | timeline                     |
single | 7 |       | Mon Feb 24 18:45:01 2014 | root | timeline | timeline                     |

This configuration can be set inside the /etc/snapper/configs/ and the parameter that is used to set the hourly snapshots is “TIMELINE_CREATE”.

If TIMELINE_CREAET is set to “YES” then the hourly snapshots are enabled else it is disabled.

Other configuration parameters include TIMELINE_LIMIT_HOURLY, TIMELINE_LIMIT_DAILY, TIMELINE_LIMIT_MONTHLY, TIMELINE_LIMIT_YEARLY

Here’s how the TIMELINE parameters are defined in the configuration file:

# cat /etc/snapper/configs/snapconfig | egrep -i TIMELINE
TIMELINE_CREATE="yes"
TIMELINE_CLEANUP="yes"
# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="10"
TIMELINE_LIMIT_MONTHLY="10"
TIMELINE_LIMIT_YEARLY="10"
  • TIMELINE_CLEANUP – Deletes the old snapshots automatically when it meets any of the below criteria
  • TIMELINE_MIN_AGE – Minimum age of snapshots are set to 30 minutes.
  • TIMELINE_LIMIT_HOURLY – Retains the last 10 snapshots
  • TIMELINE_LIMIT_DAILY – The first daily snapshot that has been taken is retained for 10 days.
  • TIMELINE_LIMIT_MONTHLY – The first monthly snapshot is retained for 10 months.
  • TIMELINE_LIMIT_YEARLY – The first snapshot taken on last day of the year is retained for 10 years.

Deleting a Snapshot Manually

Though we configured automatic cleanup in the configuration file sometimes it may be necessary to clean up the snapshots manually. Let us see how to delete the snapshots manually to free up the space on the filesystem

To delete a snapshot, do the following:

snapper –c <config file name> delete <snapshot number>

For Example:

snapper -c snapconfig delete 10

Allow Users to Use Snapper

The individual users can be granted privileges to use the snapper command to take snapshots of the directories but the config must be created by the root first. Inorder to grant permissions to the users (user1 & user2) & group (group1) the snapper configuration file must be changed to reflect like the below,

# cat /etc/snapper/configs/snapconfig | grep ALLOW
ALLOW_USERS="user1 user2"
ALLOW_GROUPS="group1"

Also the .snapshots directory permissions must be changed so that the users can read and access the directory,

The following output shows how this should look like:

# ls -ld /snapmount/.snapshots/
drwxr-x--- 1 root root 66 Feb 25 09:45 /snapmount/.snapshots/

# chmod a+rx /snapmount/.snapshots/

# ls -ld /snapmount/.snapshots/
drwxr-xr-x 1 root root 66 Feb 25 09:45 /snapmount/.snapshots/

Comments on this entry are closed.