How to make installed packages persistant with bind dirs?

I am installing snapd on debian 11.

I use bind-dir ‘/var/lib/dpkg’ to backup installed packages on whonix-ws and the remain installed on reboot.

On debian 11 /var/lib/dpkg/status mentions snapd but when I reboot it says snapd is not installed. So is there are different directory I need to backup as well?

Here is my current 50_user.conf for snapd based off of dpkg -L snapd:

binds+=( '/var/lib/dpkg' )
binds+=( '/etc/apparmor.d/usr.lib.snapd.snap-confine.real' )
binds+=( '/etc/apt/apt.conf.d/20snapd.conf' )
binds+=( '/etc/profile.d/apps-bin-path.sh' )
binds+=( '/etc/xdg/autostart' )
binds+=( '/lib/systemd' )
binds+=( '/lib/udev/snappy-app-dev' )
binds+=( '/snap' )
binds+=( '/usr/bin/snap' )
binds+=( '/usr/lib/environment.d/990-snapd.conf' )
binds+=( '/usr/lib/snapd' )
binds+=( '/usr/lib/systemd' )
binds+=( '/usr/share' )
binds+=( '/var/lib/snapd' )
binds+=( '/var/snap' )
binds+=( '/usr/bin/snapctl' )
binds+=( '/usr/bin/ubuntu-core-launcher' )

It still says snap command not found on reboot even though I specifically bind /usr/bin/snap and /usr/bin is in my path.

The dpkg folder works on whonix but I feel like I’m missing a folder for debian 11.

Any tips would be appreciated. Thanks a bunch!

EDIT: see reply below

Even after adding:

binds+=( '/var/lib/dpkg' )
binds+=( '/var/lib/apt' )
binds+=( '/etc/dpkg' )
binds+=( '/etc/apt' )

Dpkg is reporting snapd installed now but /usr/bin/snap is gone on reboot even though I have it in my bind dirs

If this means that you tried to start snap in a template prior to an AppVm, that you restarted your computer after binding, and that neither binding /usr/local/bin helps then disregard my post, please.

Doubts via Qubes OS Forum qubes_os@forum.qubes-os.org writes:

Dpkg is reporting snapd installed now but /usr/bin/snap is gone on reboot even
though I have it in my bind dirs

I remember it was not easy to grasp the first time for me … The doc says:

Creation of the files and folders in /rw/bind-dirs should be automatic
the first time the app qube is restarted after configuration.

If you want to circumvent this process, you can create the relevant file
structure under /rw/bind-dirs and make any changes at the same time that
you perform the configuration, before reboot.

(emphasize is mine)

So to make it clear, you cannot install snap in an AppVM and expect it
to survive just modifying the bind-dir array. You have to also modify
the structure under /rw/bind-dirs.

It says in the docs on reboot it will automatically copy everything in 50_user.conf to /rw/bind-dirs

So I install the app which creates all the folders in the normal file system. Edit the 50_user.conf to include all those folders and then reboot. It says it will automatically copy those folders to /rw/bind-dirs on reboot in the docs but it doesn’t.

Am I misinterpreting the docs?

Anyway ya I can create all the folders manually. I can write a script for it. I just have to create the folders and make the same file structure in /rw/bind-dirs right? I don’t have to copy the actual content from all the folders to /rw/bind-dirs right or do I?

Thanks a bunch for the help

Yes, you are. At least, you are misinterpreting what will happen
with a template based qube.

Without bind-dirs - you install the application, which creates all
folders in the normal file system.
When you reboot, only files under /rw, /home or /usr/local persist. The
rest disappear.

With bind-dirs - you install the application, which creates all
folders in the normal file system.
You configure the bind-dirs.
When you reboot, only files under /rw, /home or /usr/local persist. The
rest disappear.
Any files/directories that you specify in bind-dirs will be copied to
/rw/bind-dirs from the root filesystem, but the files/directories
created by the application have not persisted so there is nothing to
copy.

This is why you create these folders manually.
Copying the directories with content will save time and trouble.

I never presume to speak for the Qubes team.
When I comment in the Forum or in the mailing lists I speak for myself.