I have a database running in a snap that I would like to store the database data on another drive.
How can I point the configuration file (of the database) to store its data on the other drive?
(The snap is installed on the same drive as the OS, I just like to have it store its data on the external drive that is mounted)
It really depends on the snap in question. Some might support doing this through configuration, or you can e.g. mount the other drive onto e.g.
/var/snap (assuming the database is in
The database itself runs as a single binary with one configuration file (with the option to declare where to store the data). So I have complete control of the yaml and the snap itself.
You mention I can mount the other drive onto /var/snap, will all snaps as a result store their data on the external drive as well then?
/var/snap but only as a hit i think.
the actual value $SNAP_DATA translates to is
/var/snap/<snapname>/current, so you would create a mountpoint like
/var/snap/<snapname>/current/db-mount and have your snap access this as
$SNAP_DATA/db-mount this works without any interfcaces added to your app and without affecting any other snaps.
if you dont mind to add an interface you can also pick the
removable-media interface plug in your apps entry in snapcraft.yaml, connect it after installing the snap and access anything mounted under /media (so you’d mount your disk in
/media/<mydisk> and access your db file from there)