wesbarnett / snap-pac

Pacman hooks that use snapper to create pre/post btrfs snapshots like openSUSE's YaST
GNU General Public License v2.0
180 stars 14 forks source link

Pacman locked in snapshots #6

Closed NicoHood closed 7 years ago

NicoHood commented 7 years ago

I recently needed to restore an older snapshot of my root. I've followed this instructions.

This were my snapshots:

pre    | 19 |       | Sun Jul 31 05:46:51 2016 | root | number  | pacman -U /home/alarm/AUR/buttersink-git/buttersink-git-0.6.8.r0.gb0ca6ef-1-any.pkg.tar.xz
post   | 20 | 19    | Sun Jul 31 05:46:53 2016 | root | number  | pacman -U /home/alarm/AUR/buttersink-git/buttersink-git-0.6.8.r0.gb0ca6ef-1-any.pkg.tar.xz

I've restored snapshot 20 and when i tried pacman -Syu it gave me:

$ sudo pacman -Syu
:: Synchronizing package databases...
error: failed to update core (unable to lock database)
error: failed to update extra (unable to lock database)
error: failed to update community (unable to lock database)
error: failed to update alarm (unable to lock database)
error: failed to update aur (unable to lock database)
error: failed to synchronize any databases
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck

I am not sure if you can conside that in snap-pac. A delay might also be somehow ugly.

wesbarnett commented 7 years ago

It's not really a snap-pac issue. I don't know you're btrfs layout (which subvolumes, etc). I suggest posting this on the arch forum.

NicoHood commented 7 years ago

I am using the suggested btrfs layout. This means @/ mounted as / get backed up. And in the path is the file /var/lib/pacman/db.lck which will be created when pacman is run. So this pacman hooks needs to ensure that this file is removed before the pre hook runs (aka pacman is not locked anymore). I am not sure if a hook for pacman can run that late.

https://bbs.archlinux.org/viewtopic.php?pid=1652907#p1652907

wesbarnett commented 7 years ago

I don't think snap-pac should be touching /var/lib/pacman/db.lck. That file is never in any pre/post snapshot I have taken when using pacman/snap-pac. It sounds like a pacman error occurred and it was left behind when a snapshot was taken, but I'm not sure.

NicoHood commented 7 years ago

screenshot_2016-09-09_21-14-36 I am sorry, but this file is in every pre/post snapshot I've made.

wesbarnett commented 7 years ago

I stand corrected. I do have the db.lck file in pre/post snapshots (I mistakenly looked at the timeline ones). The pre snapshot is the very first snapshot taken and the post snapshot is the very last one. I don't think there's a way to make them earlier/later than when pacman creates this file. Thanks for bringing it back up.

Solution 1: Document that users need to remove this manually when restoring from a snapshot. Solution 2: Document that users can exclude the path from snapshots by making it a subvolume (but would also exclude subdirs). Solution 3: Have snap-pac mess with the file - I don't think that is a good idea or feasible.

Other ideas?

NicoHood commented 7 years ago

I can only think of solution 1 for now. Solution 2 is not a good idea, as this will remove the installed package structure from the backup. Solution 3 is also too hacky. The file has its purpose.

Another idea would be to ask if we can change pacman itself, that you can have pre lock hooks and past lock hooks.

wesbarnett commented 7 years ago

Added info about this to troubleshooting section, so closing.

NicoHood commented 7 years ago

Thanks. I'd add the acutal path to the file like this:

"removing the lock file in /var/lib/pacman/db.lck."

wesbarnett commented 7 years ago

That's the default location, but it could be present somewhere else if the user changes pacman.conf's settings (RootDir, DBPath, etc.). Pacman gives the exact location to the user when present.

NicoHood commented 7 years ago

Then possibly only add db.lck. I am saying this, so you can search for this error better. If its in the readme I'd search for those keywords (as I did when you said you added it). Just a suggestion from my side. But thanks for the note, its good to know that its not essentially this path.

D3vil0p3r commented 1 year ago

Hello guys. I understand that touching directly db.lck could be not a good idea as first impression, I think could be good that, after a snapshot restore, snap-pac popup a window with the message like "If you get the error xxxxx pacman locked db xxxx, run rm -rf /var/lib/pacman/db.lck for unlocking pacman"

DodoLeDev commented 1 year ago

It is also possible to create filters for that file!