- Home
- Packages
- Forums
- Wiki
- Bugs
- AUR
- Download

# Snapper

From ArchWiki

Summary
A tool for creating snapshot timelines on Btrfs and LVM volumes
Related
Btrfs
Installing on Btrfs root
Btrfs - Tips and tricks

Snapper is a tool created by openSUSE's Arvin Schnell that helps with managing snapshots of Btrfs subvolumes and LVM volumes. It can create and compare snapshots, revert between snapshots, and supports automatic snapshots timelines.

## Installation

The package snapper-git is available on the AUR.

## Setup automatic timeline snapshots

Snapper can create a snapshot timeline with a configurable number of snapshots kept per hour/day/month/year.

The implementation works as follows:

- By default a snapshots gets created once an hour (cron.hourly)
- Once a day the "old and unwanted" snapshots get cleaned up by the timeline cleanup algorithm (cron.daily)

There is also a number cleanup algorithm, see `man snapper` for details.

Here is an example `snapper -c root list` output of a configuration with only 7 days of snapshots, no monthly, no yearly ones:

    # snapper -c root list

    Type   | #    | Pre # | Date                     | User | Cleanup  | Description | Userdata
    -------+------+-------+--------------------------+------+----------+-------------+---------
    single | 0    |       |                          | root |          | current     |
    single | 3053 |       | Tue Oct 22 00:01:02 2013 | root | timeline | timeline    |
    single | 3077 |       | Wed Oct 23 00:01:01 2013 | root | timeline | timeline    |
    single | 3101 |       | Thu Oct 24 00:01:01 2013 | root | timeline | timeline    |
    single | 3125 |       | Fri Oct 25 00:01:01 2013 | root | timeline | timeline    |
    single | 3149 |       | Sat Oct 26 00:01:01 2013 | root | timeline | timeline    |
    single | 3173 |       | Sun Oct 27 00:01:01 2013 | root | timeline | timeline    |
    single | 3197 |       | Sun Oct 27 23:01:01 2013 | root | timeline | timeline    |
    single | 3198 |       | Mon Oct 28 00:01:01 2013 | root | timeline | timeline    |
    single | 3199 |       | Mon Oct 28 01:01:01 2013 | root | timeline | timeline    |
    single | 3200 |       | Mon Oct 28 02:01:01 2013 | root | timeline | timeline    |
    single | 3201 |       | Mon Oct 28 03:01:02 2013 | root | timeline | timeline    |
    single | 3202 |       | Mon Oct 28 04:01:01 2013 | root | timeline | timeline    |
    single | 3203 |       | Mon Oct 28 05:01:02 2013 | root | timeline | timeline    |
    single | 3204 |       | Mon Oct 28 06:01:01 2013 | root | timeline | timeline    |
    single | 3205 |       | Mon Oct 28 07:01:02 2013 | root | timeline | timeline    |
    single | 3206 |       | Mon Oct 28 08:01:01 2013 | root | timeline | timeline    |
    single | 3207 |       | Mon Oct 28 09:01:01 2013 | root | timeline | timeline    |
    single | 3208 |       | Mon Oct 28 10:01:01 2013 | root | timeline | timeline    |
    single | 3209 |       | Mon Oct 28 11:01:01 2013 | root | timeline | timeline    |
    single | 3210 |       | Mon Oct 28 12:01:01 2013 | root | timeline | timeline    |
    single | 3211 |       | Mon Oct 28 13:01:01 2013 | root | timeline | timeline    |
    single | 3212 |       | Mon Oct 28 14:01:01 2013 | root | timeline | timeline    |
    single | 3213 |       | Mon Oct 28 15:01:01 2013 | root | timeline | timeline    |
    single | 3214 |       | Mon Oct 28 16:01:01 2013 | root | timeline | timeline    |
    single | 3215 |       | Mon Oct 28 17:01:01 2013 | root | timeline | timeline    |
    single | 3216 |       | Mon Oct 28 18:01:01 2013 | root | timeline | timeline    |
    single | 3217 |       | Mon Oct 28 19:01:01 2013 | root | timeline | timeline    |
    single | 3218 |       | Mon Oct 28 20:01:01 2013 | root | timeline | timeline    |

### Prepare your Subvolume(s)

Snapper expects a `.snapshots` subvolume in the root of the subvolume to be snappered. This needs to be created manually.

Example: the BTRFS root volume is mounted to `/mnt/rootfs` and the subvolume to be snappered is `/mnt/rootfs/arch-root`

    # btrfs subvolume create /mnt/rootfs/arch-root/.snapshots

### Prepare the configuration

Snapper comes with a default configuration template in `/etc/snapper/config-templates`.

Copy it under a new name to `/etc/snapper/configs/`.

    # cp /etc/snapper/config-templates/default /etc/snapper/configs/root

Edit the config and set at least `SUBVOLUME="..."`

    /etc/snapper/configs/root

    # subvolume to snapshot
    SUBVOLUME="/mnt/rootfs/arch-root"

    # create hourly snapshots
    TIMELINE_CREATE="yes"

    # cleanup hourly snapshots after some time
    TIMELINE_CLEANUP="yes"

Note: For informations on all the other settings in the configs see `man snapper-configs`.

### Enable the configuration

To actually enable the configuration, add the basename of your config file to `/etc/conf.d/snapper`

    SNAPPER_CONFIGS="root home"

## Pre-Post snapshots with pacman

Snapper can create snapshots "tagged" as pre or post snapshots. This is handy when it comes to system upgrades. Using `NUMBER_CLEANUP="yes"` those can get cleaned up after a configurable number of snapshots using the number cleanup algorithm - see `man snapper` and `man snapper-configs` for details.

To use this feature with pacman, you will need some wrapper script. User erikw created one for this purpose called snp.

## Caveats

- Many snapshots with a large timeframe of a busy filesystem (like /, where many system updates happen over time) can cause serious slowdowns. Create subvolumes for things that are not worth to be snapshotted, like `/var/cache/pacman/pkg` and `/var/abs`

Retrieved from "https://wiki.archlinux.org/index.php?title=Snapper&oldid=280319"
Category:

- File systems

## Navigation menu