2 Snapshots #
This chapter describes managing snapshots and gives details about directories included in snapshots.
As snapshots are crucial for the correct functioning of SLE Micro, do not disable the feature, and ensure that the root partition is big enough to store the snapshots.
When a snapshot is created, both the snapshot and the original point to the same blocks in the file system. So, initially a snapshot does not occupy additional disk space. If data in the original file system is modified, changed data blocks are copied while the old data blocks are kept for the snapshot.
Snapshots always reside on the same partition or subvolume on which the snapshot has been taken. It is not possible to store snapshots on a different partition or subvolume. As a result, partitions containing snapshots need to be larger than partitions which do not contain snapshots. The exact amount depends strongly on the number of snapshots you keep and the amount of data modifications. As a rule of thumb, give partitions twice as much space as you normally would. To prevent disks from running out of space, old snapshots are automatically cleaned up.
Snapshots that are known to be working properly are marked as important.
2.1 Directories excluded from snapshots #
As some directories store user-specific or volatile data, these directories are excluded from snapshots:
- /home
- Contains users' data. Excluded so that the data will not be included in snapshots and thus potentially overwritten by a rollback operation. 
- /root
- Contains root's data. Excluded so that the data will not be included in snapshots and thus potentially overwritten by a rollback operation. 
- /opt
- Third-party products usually get installed to - /opt. Excluded so that these applications are not uninstalled during rollbacks.
- /srv
- Contains data for Web and FTP servers. Excluded in order to avoid data loss on rollbacks. 
- /usr/local
- This directory is used when manually installing software. It is excluded to avoid uninstalling these installations on rollbacks. 
- /var
- This directory contains many variable files, including logs, temporary caches, third-party products in - /var/opt, and is the default location for virtual machine images and databases. Therefore, a separate subvolume is created with Copy-On-Write disabled, so as to exclude all of this variable data from snapshots.
- /tmp
- The directory contains temporary data. 
- the architecture-specific /boot/grub2directory
- Rollback of the boot loader binaries is not supported. 
2.2 Showing exclusive disk space used by snapshots #
   Snapshots share data, for efficient use of storage space, so using ordinary
   commands like du and df won't measure
   used disk space accurately. When you want to free up disk space on Btrfs
   with quotas enabled, you need to know how much exclusive disk space is used
   by each snapshot, rather than shared space. The btrfs
   command provides a view of space used by snapshots:
  
# btrfs qgroup show -p /
qgroupid         rfer         excl parent  
--------         ----         ---- ------  
0/5          16.00KiB     16.00KiB ---     
[...]    
0/272         3.09GiB     14.23MiB 1/0     
0/273         3.11GiB    144.00KiB 1/0     
0/274         3.11GiB    112.00KiB 1/0     
0/275         3.11GiB    128.00KiB 1/0     
0/276         3.11GiB     80.00KiB 1/0     
0/277         3.11GiB    256.00KiB 1/0     
0/278         3.11GiB    112.00KiB 1/0     
0/279         3.12GiB     64.00KiB 1/0     
0/280         3.12GiB     16.00KiB 1/0     
1/0           3.33GiB    222.95MiB ---
   The qgroupid column displays the identification number
   for each subvolume, assigning a qgroup level/ID combination.
  
   The rfer column displays the total amount of data
   referred to in the subvolume.
  
   The excl column displays the exclusive data in each
   subvolume.
  
   The parent column shows the parent qgroup of the
   subvolumes.
  
   The final item, 1/0, shows the totals for the parent
   qgroup. In the above example, 222.95 MiB will be freed if all subvolumes are
   removed. Run the following command to see which snapshots are associated
   with each subvolume:
  
# btrfs subvolume list -st /