Hello
I wrote backup app and want create snap for it and it is supposed to run this app form time to time (not permanently).
I googled over 2h and I am confusing… I find out:
snap package is mounted read only in user system
snapcraft.yaml define how to build snap
meta/snap.yaml in side package configure snap at runtime
I also find out here that meta/snap.yaml file can be configured (I don’t know how) to run snap app at specific time:
# The service is activated by a timer, app must be a daemon. See timer
# documentation for examples.
# (snapd 2.33+)
timer:
Fortunatelly I have snapd v2.38 . So I think I can eventually use this feature.
I see 2 problems:
How can I change meta/snap.yaml ? I ask because it is not clear to me whether is this file automatically generated or not.
I need to allow users define they own scheduler (they should decide when they want to make backup). But when snap package is read only mounted (especially meta/snap.yaml file), then: How can I define scheduler from my app (it is supposed to run my app with command line options in order to define backup parameters).
Snap timers are designed for application developers to use and are not user-configurable. You cannot change meta/snap.yaml. If you want you can create a systemd timer unit or a crontab entry to use schedule execution at a given time.
Thank you for your reply.
I have one more question:
Have I declare (in snapcraft.yaml) access in to /etc/system/systemd directory?
Or can I simply use sudo when I write config into user system?
Snaps cannot write to that location. Even as root snap application processes run inside the execution sandbox.
Perhaps what you want is to say, run once an hour after installation? You can define a snap timer in snapcraft.yaml, snapd will generate a corresponding systemd timer.
It is backup app. I can’t imagine in what time period it should be run. It depends how many directories will be chosen to backup, how large they are, and what are target directories (some of them can be slow as pendrive, or network), and kind of type data is also important. The best solution for this kind of app is make them fully configurable. But it seems it is not possible…
It is a pity as it is very basic use case which is not covered by snap…
Thank you.
You have two or three approaches, depending on the answer to that question.
the snap developer can ship the snap with a service that runs on a timer. This is useful for things that intrinsically need to run periodically, such as daily reporting service, or an hourly bandwidth usage summariser, or something like that.
the system administrator (the same person that installed the snap) can create a timer themselves, to trigger something in the snap periodically. They access to the full syntax described in systemd.timer.
the user could run a configuration script that requests a background service do something periodically. This one is the most tricky because the thing crosses a bunch of permission / sandbox lines, and getting it right might be hard.
the user could run a configuration script that requests a background service do something periodically. This one is the most tricky because the thing crosses a bunch of permission / sandbox lines, and getting it right might be hard.
This is probably this case. Except it is not script - it is C++ app which is supposed to performs backup specific dirs (witch filter and compression) to specific target dirs.
And it is not customizable at the moment. But I want to make command line option for this.
My intention is:
make option: define directories for backup
make option: define directories where to store backups
make option: how often make backups (I wan’t store Kopia.timer template and update /etc/systemd/system with sudo permissions)
I think it is simple and power full.
Btw: If you know what generic packages allowed this please let me know (but I am not interested with distro specific packages).