Hooking the pacman update process

As a user of firefox on the testing branch, I have discovered that the browser really doesn’t like to be downgraded. This is usually the case after a timeshift restore. The problem is that the firefox profile(s) are for the newer version and cannot be used with the older.

Forgive me if I missed a package in the AUR, but I’d like to see one which would backup the firefox profile(s) before a system update. I’d be very thankful if somebody is willing to make and publish such a package. In the mean time, how can I hook the pacman update process so that I can run a local “backup” script?

It’s not what you are looking for, but i backup my whole /home/username with all the hidden and everything… that means I get my firefox profiles and such…

So if I needed to revert, I’d simply restore the firefox to the date prior to the downgrade (~/.mozilla/firefox is the typcial folder.).

On the other hand, I highly value privacy, so i’ve configured firefox to simply not save anything… I manage my accounts and bookmarks elsewhere — so… I have nothing to restore… :smiley:

if you want, you can use create a small script like you suggested and run it instead of typing
sudo pacman -Syu

to start, open the Konsole:
[julius@Pinebook ~]$ nano update.sh
note that you can use whatever texteditor you like instead by replacing nano with kate for example

in the window write the following lines:

#!/usr/bin/env bash
echo “This is my small update script :)”
echo “Backing up the firefox profile”
cp -r ~/.mozilla/ ~/.moz_backup/
echo “done”
echo “running pacman -Syu”
sudo pacman -Syu

then you need to make the file executable with
chmod +x ~/update.sh

This is now fully functional :slight_smile: you can just execute it with ~/update.sh.

to add this script to your path, first do

[julius@Pinebook ~]$ mkdir ./.my_scripts
[julius@Pinebook ~]$ mv ./update.sh ./.my_scripts/

then do nano ~/.bashrc and add the following line:
export PATH=~/.my_scripts/:$PATH
congrats, you can now do update.sh from anywhere in your console to upgrade your system and perhaps how to write a small bash script to do what you want.
Reboot and then:

just type update.sh

Best Regards, Julius

Or it could be placed in ~/.local/bin/ since it’s already in the default $PATH. :wink:

1 Like

I looked into how timeshift-autosnap works and discovered I can place a hook in /usr/share/libalpm/hooks/

Something like:

Operation = Upgrade
Type = Package
Target = *

Description = Backup Firfox profiles on pacman update.
When = PreTransaction
Exec = /usr/bin/backup-firefox-profiles.sh

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