Using snapper to snapshoot and restore a system

Perfect! That was it! Thanks for ever forever!

1 Like

I actually run it like this

sudo snapper -c root create-config /

as in the arch wiki, but I think the result is the same right? Also this mean that snapper will only create snapshot of @root right?

Those commands have identical meaning and results. Your version is just more typing. :laughing:

That means you will have created a snapper config for only root. Whether or not that will result in actual snapshots depends on your settings and configuration.

I installed EndeavourOS using btrfs and installed and set up snapper but there are a number of things i do not understand. I watched a number of good youtube videos and also read the Arch wiki and some things don’t make sense.

The arch wiki say’s to install snapper. That’s the easy part. This is the part i don’t get.

Before creating a snapper configuration for a Btrfs subvolume, the subvolume must already exist. If it does not, you should create it before generating a snapper configuration. This part i understand. The next i don’t.

To create a new snapper configuration named config for the Btrfs subvolume at /path/to/subvolume, run:

snapper -c config create-config /path/to/subvolume

This will:

  • Create a configuration file at /etc/snapper/configs/config based on the default template from /etc/snapper/config-templates.
  • Create a subvolume at /path/to/subvolume/.snapshots where future snapshots for this configuration will be stored. A snapshot’s path is /path/to/subvolume/.snapshots/#/snapshot, where # is the snapshot number.
  • Add config to SNAPPER_CONFIGS in /etc/conf.d/snapper.

For example, to create a configuration file for the subvolume mounted at /, run:

snapper -c root create-config /

I only used the last on here. I don’t think you are supposed to do both. What is the difference between these two? Endeavouros Creates 4 subvolumes so i don’t have to do that.

Also i can’t create a subvolume for /home unless i have a home partition? Correct? So if i had a separate /home partition then it would need a subvolume for @ /home also and the Clamares installer would create that if i used manual partitioning and created it on the install? What is the advantage or disadvantage of doing that? Or am i confused here because i see @home listed. So whats the difference between having a separate /home partition then?

The rest of it i sort of understand. I am using the systemd timers because my knowledge on cron is not good. So this is easy as i am used to setting services using systemctl. Doing manual snapshots i can follow.

So i also installed grub-btrfs so the snapshots show up in the grub menu. I configured the snapshot time limits. I did not set access for non root users since I’m the only user i didn’t think it matters to change that.

I also tried to follow the videos and the arch wiki for Backup non-Btrfs boot partition on pacman transactions. The videos were a different hook and even the one in Arch wiki did not work. They both complain about it won’t run due to some dependency issues.

So i installed snap-pac from the AUR and it works flawlessly to create a before and after snapshot.
I also enable the snapper boot timer.

So i think it’s set up correctly and working. Not totally understanding why we need 4 subvolumes if it only is taking snapshots of @?

Also to know how to use the snapshots to restore? Is this done from the terminal with commands only. I don’t think the snapper GUI tool is for restoring just for creating snapshots i think? Or i have to chroot to do it everytime. Or that’s only if it won’t boot?

Edit: It looks like it’s all working.

Screenshot_20210818_100229

Edit2: I only have this config because i didn’t create a /home partition. If i install this again i may add that.

[ricklinux@eos-kde ~]$ snapper list-configs
Config | Subvolume
-------+----------
root   | /        
[ricklinux@eos-kde ~]$ 

I guess the idea behind creating @log (mounted at /var/log) and @cache /mounted at /var/cache) is to exclude them from the snapshot of the root filesystem, if I am not mistaken. Perhaps for limiting the size of the snapshots to what is absolutely essential.

I have been trying to visualize the idea of subvolumes like containers within containers. In this case a big BTRFS partition serves as the “overall” container within which you could have as many “sub-containers” you wish. EnOS’ Calamares creates 4 such “sub-containers” within the big one. They are all mounted at their appropriate mounpoints via fstab.

This is in effect a much efficient management of disk space than having fixed sized partitions for each.

This is my understanding of it so far but surely I’ve got something wrong or misunderstood.

1 Like

The first one isn’t a real command. It is instructions about what the command would look like generally.

No. Multiple subvolumes can live inside a single partition.

Yes, exactly.

In the case of @cache, there is no reason to take or restore snapshots of cache.

For @log, it is the opposite reason. It is so the logs are preserved if you need to rollback a snapshot.

1 Like

Interesting! Thanks for bringing in light as always!

1 Like

The reason i asked about the configuration is because i ran the first one and it worked and i couldn’t understand what the difference was.

Also with respect to having a separate /home partition? So that doesn’t really change anything in the subvolumes it creates? It’s still @home as a subvolume but instead of home being in root it’'s a partition? Correct? So am i able to create a config for @home or not because i don’t have a separate partition for home? That’s the part i don’t understand because i tried to create a config for home and it doesn’t work.

Edit: What i meant was i ran this to create the config.

snapper -c config create-config /

Yes.

sudo snapper -c home create-config /home

That creates a config name “config” which points to your root.

If you do:

sudo snapper list-configs

You will probably see you have two configs for /

Okay but what does the snapshot of that do?

Which snapshot of what are you referring to?

If i create a config for @ home what does that do then? I’m not sure if I’m asking the right question? What’s the purpose? Does it creat snapshots of just the home within the root separate from the root config?

Edit: I’m asking because i don’t have a separate home partition so i don’t understand what the difference is and what i can do with it?

When you choose to snapshot your home subvolume, it uses the parameters defined in the config file that you have created. The snapshots then will be put at @home/.snapshots. Hope I got that right.

No. But you have a separate home subvolume.

Creating a config is what allows you to take snapshots. The configs are not snapshots themselves.

If you create a config for home, you then have the ability to take snapshots of /home

If you have the snapper-timeline or snapper-boot timers enabled, it will start taking snapshots. If not, nothing will happen.

So then what’s the point of having a separate home partition?

Partition or subvolume? When using btrfs, you usually don’t need a separate partition.

1 Like

That’s exactly the point! It has no point at all in such a setup.

1 Like

That’s the answer i was looking for. But with the other Btrfs setup on Timeshift and snapshots it’s different. So you would need the separate partition or does it also do home?

Okay so i created the /home config. Do i have to have separate timeline settings for it in a conf file?

When you create the config it automatically creates those for you. If you want to modify them they are in a subdirectory of /etc/snapper