Featured image of post Timeshift BTRFS Backups on Manjaro

Timeshift BTRFS Backups on Manjaro

Automated system backups before package installation

Introduction

Timeshift is a great tool! It helps making automated system backups. You can do it manually if you want to, but BTRFS snapshots are where it’s at!

  1. Copying somewhere with rsync, with clever linking to save space as much as possible
  2. Using BTRFS snapshot

The first option is pointless. This takes forever and isn’t exciting, but BTRFS is what you need! It’s done instantly and where duplicates are, the file system saves it itself. Plus, you can load them right when booting up.

System Requirements

Part of the page on the main repository, but I also found some more:

  1. The default subvolume for the BTRFS filesystem should be /

When mounting a BTRFS partition either without specifying the mount option subvol= it will mount at the root. If not, the program crashes. Here’s a script to check and correct this:

1
2
3
4
MP="$(mktemp -d)"
mount | awk '/on \/ type btrfs/{print $1}' | sudo xargs -I{} mount {} "$MP" && \
sudo btrfs subvolume set-default 5 "$MP"; \
sudo umount "$MP"
  1. The root filesystem partition in /etc/fstab should be correctly configured

The same subvol= option should be set to either @* or /@, it doesn’t matter. Here’s a script to tell if everything is correct:

1
2
3
4
5
6
grep -E '^[^#].+/\s+btrfs' /etc/fstab | \
grep -oE 'subvol=[^,]+' | \
cut -d= -f2 | \
grep -qE '^/?@$' && \
echo 'OK' || \
echo 'Not OK'

How it works

When installing any package through pamac or yay, timeshift automatically kicks in if etc/timeshift-autosnap.conf doesn’t include its skip.

And now I have two backups too

Licensed under Apache License, Version 2.0
Last updated on Nov 19, 2024 10:58 +0200
All rights reserved
Built with Hugo
Theme Stack designed by Jimmy