How to Update Grub Every Time I Make an Snapshot (Automatically)?

I recently installed Manjaro [stable] with GNOME and BTRFS. I also installed Timeshift and grub-btrfs to manage snapshots and successfully restored my system a couple of times while testing their funcionality.

However, I’ve noticed that after creating a snapshot with Timeshift, I need to open up the terminal and run sudo update-grub otherwise the newly created snapshots won’t appear in the grub menu, only the old ones. Is there a way to automate this process?

Not knowing anything much about how timeshift is managed here,
I might just suggest an alias?
Something like

alias btup='btrfs subvolume snapshot source /some/path/name && update-grub'

Or, considering update-grub is no longer default, and including the sudo trick;

alias sudo='sudo '
alias btup='btrfs subvolume snapshot source /some/path/name && grub-mkconfig -o /boot/grub/grub.cfg'

(with /some/path/name being replaced in both examples)

Pardon my ignorance, but what is an alias? I quick search told me its like a custom keyboard shortcut that executes a command, so basically its like when I (from GNOME settings) set a specific shortcut to launch an application. For example: I’ve set super + m to launch Rhythmbox and super + b to launch Firefox.

So, in summary you are telling me to create a shortcut/alias that launches Timeshift to create an snapshot and updates grub afterwards. Did I get it right? Because that would be a great idea.

An alias is like a shortcut.
But for a string entered into the terminal.
It is a command, so you can enter it like so:

alias sysinfo='inxi -Farzy'

And then … if you enter sysinfo into the terminal and press Enter … it will perform that inxi command.

Similarly, you can place a line like that in your shells rc file (~/.bashrc for bash) so that you always have access to that command.

For example to achieve ‘update-grub’ without the package I have in mine

alias sudo='sudo '
alias update-grub='grub-mkconfig -o /boot/grub/grub.cfg'

(this is an example of using the sudo trick mentioned above … which is required to be able to pass sudo to aliases. The other approach is to include sudo in the alias itself.)

A recent thread/post discussed aliases as well

Do note that the above suggestion used examples … I do not know what/how you exactly you make your snapshots, or where they are located etc.

But yes, the gist of the idea was to combine both steps (make a snapshot, run grub-mkconfig/update-grub) into a simple single alias.

Got it. Thanks for pointing me in the right direction.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.