User Tools

Site Tools


Schnapps

Schnapps is a tool for managing snapshots, which are states of the operating system at a given moment in time. Snapshots can be created manually - how to do that is explained in this article - but they are also created automatically whenever the system is updated and also periodically once a week.

Thanks to Schnapps, it is possible to return to a previous version of the OS, for example, to test the functionality of this particular version or in case of OS failure. This is why, if you plan to make major changes to the system, we recommend that you create a snapshot before hand, to which you can return in the event that something goes wrong. You can also return to the latest snapshot simply by pressing the reset button until two diodes are light up and you can read about this simple rescue in Factory reset on Turris Omnia. This manual contains the instructions for a more advanced use of snapshots.

A few useful commands for working with Schnapps:

  • schnapps help – a complete list of commands and their functions
  • schnapps create – creates a snapshot
  • schnapps list – prints a list of available snapshots
  • schnapps rollback – rolls back to a specific snapshot
  • schnapps cmp – compares snapshots
  • schnapps diff – compares snapshots with more details

How to create a snapshot and how to return to a specific snapshot:

Connect to the router through SSH. You can make use of the argument desc, to give the snapshot you are creating a description and make later orientation in the snapshots easier:

root@turris:~# schnapps create "Everything works"
Snapshot number 24 created

Schnapps created a snapshot, in this case snapshot number 24. Using the command schnapps list, check that this has really been done. This is the sort of output that you can expect:

root@turris:~# schnapps list
    # | Type      | Date                      | Description
------+-----------+---------------------------+---------------------------------
   11 | rollback  | 2017-01-12 12:03:09 +0000 | Rollback to snapshot 7
   12 | rollback  | 2017-01-12 12:40:38 +0000 | Rollback to snapshot 6
   14 | rollback  | 2017-01-12 14:27:35 +0000 | Rollback to snapshot 13
   17 | pre       | 2017-01-24 13:00:28 +0100 | Automatic pre-update snapshot
   18 | pre       | 2017-02-02 14:02:24 +0100 | Automatic pre-update snapshot
   19 | pre       | 2017-02-13 09:41:45 +0100 | Automatic pre-update snapshot
   20 | pre       | 2017-02-13 11:05:48 +0100 | Automatic pre-update snapshot
   21 | pre       | 2017-02-20 14:02:12 +0100 | Automatic pre-update snapshot
   22 | pre       | 2017-03-15 14:02:11 +0100 | Automatic pre-update snapshot
   23 | pre       | 2017-03-21 10:11:22 +0100 | Automatic pre-update snapshot
   24 | single    | 2017-03-21 11:02:02 +0100 | Everything works

Notice that the older snapshots are missing from this list. Snapshots, which are automatically created before updates are regularly deleted as are the periodically created weekly snapshot, of which only the newest are kept. Those snapshots, which do not differ from other ones are also deleted.

Using the command schnapps cmp [number] [number] you can compare two snapshots, to see what is missing or extra in one version in comparison to the other. For example:

root@turris:~# schnapps cmp 23 24
Comparing snapshots 23 and 24
This can take a while, please be patient.
Meaning of the lines is following:

   - file    file present in 23 and missing in 24
   + file    file not present in 23 but exists in 24
   ~ file    file in 23 differs from file in 24

 ~ /.rnd
 ~ /etc/config/ucitrack
 + /etc/cron.d/.keep
 + /etc/crontabs/.keep
 ~ /etc/dhparam/dh2048.pem
 ~ /etc/turris-version
- /lib/upgrade/keep.d/vixie-cron
...

If you want to check the OS version of a given snapshot, this can be useful for example if you want to return to a specific version, you can do so using the following two commands:

root@turris:~# schnapps mount 19
Snapshot 19 mounted in /mnt/snapshot-@19
root@turris:~# cat /mnt/snapshot-@19/etc/turris-version
3.5.2

Next, with use of the command schnapps rollback [number] you return to the selected snapshot. The current state of the system will be automatically saved as the next snapshot:

root@turris:~# schnapps rollback 23
Current state saved as snapshot number 25
Rolled back to snapshot 23

+ PARTITION=/dev/mtdblock4
+ WORKDIR=/tmp/certstore
+ SUBVOL=certbackup
+ dirname /tmp/certstore
+ mkdir -p /tmp
...

In the last step, it is necessary to reboot the router (manually or via the reboot command). The system will boot to a copy of the system, which was preserved in the moment the selected snapshot was created.

Disclaimer: The system will understandably not remain in the state, which the snapshot represents, forever. After a few hours, updates will automatically be installed and from the time of the reboot, the system “starts living its own life again”. This means that the Schnapps tool cannot be used for inducing a kind of permanent static state of the OS.