Skip to main content

Timeshift

IMPORTANT: Timeshift is not a backup tool! It only creates local snapshots of the system to roll back changes to the system. Do not rely on this mechanism to keep your data safe! Timeshift deletes the oldest snapshot when a new one is created and restorethe maximum number of snapshots is reached. Furthermore, if the underlying file system is corrupted, the snapshots will be, too! Use a proper backup tool utilizingto eitherkeep your data safe on external data storage!

Timeshift helps create incremental snapshots of the file system at regular intervals, which can then be restored at a later date to undo all changes to the system.

It supports rsync orsnapshots btrfsfor snapshots.

all

Installation

filesystems,

WARNING:and Timeshift'suses btrfsthe modebuilt-in issnapshot limitedfeatures for Btrfs drives configured to anuse "Ubuntu-style" subvolume layout, i.e. onlythe @ and @home subvolumessubvolume canlayout befor present.root and home directories respectively.

Installation

InstallTimeshift Timeshiftis available from the AUR:Arch repos. It uses cron to make regularly scheduled backups. Install Timeshift with a cron daemon, e.g. cronie:

yaypacman -S timeshift cronie

Configuration

Start

Cron

and

Timeshift relies on cronjobs to periodically create snapshots. Startenable the cron daemonscheduler via:for Timeshift to take regular snapshots:

sudo systemctl enable --now cronie

Additionally,Finally, create an empty crontab file:

ATTENTION: If the EDITOR environment variable is not set crontab automatically calls vi to edit files. Either export it or supply it temporarily when calling crontab, e.g. EDITOR=nano crontab -e to use nano instead of vi.

sudo crontab -e

Timeshift first time launch wizard

ATTENTION: The GUI wizard is buggy around btrfs and lvm setups. It will say no btrfs partitions were detected but lets you continue regardless if you select the device with the root btrfs partition.

Open Timeshift via the desktop launcher and complete the configurationfirst wizard.time setup.

Automatic snapshots on system changes

In addition to Timeshift's periodic spanshots, timeshift-autosnap provides a pacman hook to create a manual snapshot every time packages are installed, upgraded or removed. It works with either rsync or btrfs mode of Timeshift.

Install timeshift-autosnap from the AUR:

TIP: When using GRUB as your bootloader consider also installing grub-btrfs to include btrfs snapshots in GRUB boot options.

yay -S timeshift-autosnap

By default timeshift-autosnap only keeps 3 snapshots and deletes older ones.snapshots. To change this, edit /etc/timeshift-autosnap.conf and either set deleteSnapshots to false to never delete any snapshots or increase the number of maxSnapshots, for example::

skipAutosnap=false
deleteSnapshots=true
maxSnapshots=7
updateGrub=true
snapshotDescription={timeshift-autosnap} {created before upgrade}

Prevent excessive snapshotting when using yay

By default, when installing or updating multiple packages from the AUR, yay first builds a package and immediately calls pacman to install it, before building and installing the next one on its list. This also means that the timeshift-autosnap hook is triggered for each individual AUR package built by yay, including dependencies also installed from the AUR.

This can have undesireable side-effects:

  • yay will cause timeshift-autosnap to reach the maxSnapshots limit very quickly when installing multiple packages from the AUR, causingleaving timeshift-autosnapyou with snapshots with little to deleteno snapshotsmeaningful youchanges maybetween have wanted to keepthem
  • if deleteSnapshots is set to false the availableamount of snapshots might quickly exhaust the usable space on the btrfs partition may quickly be exhausted with an absurd amount of snapshots takendrive

To prevent this it is recommended to configure yay to:

  1. not remove make dependencies after successfully built packages are installed
  2. build all AUR packages first, install them all later
  3. install AUR packages together with regular repo packages

By calling yay with the --save parameter, any options passed to it will be saved in a configuration file, e.g.:

yay --noremovemake --batchinstall --combinedupgrade --save  

Next time you use yay to install, upgrade or remove packages it will read the generated config file at ~/.config/yay/config.json and apply the options automatically without having to specify them during use.