How to properly schedule?

For clarity, my various repos have these various timers set up in directory:

/etc/systemd/system

kopia_host1_snapshot_NAS-1-2-3-4.timer
kopia_host1_snapshot_NAS-1-2.timer
kopia_host1_snapshot_NAS-3-4.timer

kopia_host1_snapshot_@.service

If you are not so familiar with systemd the repo names are substituted as args into the service file, so that to run the respective service timers directly (immediately) you can also use (in generic form):

systemctl start kopia_host1_snapshot_@<SNAPSHOT_GROUP>.service
systemctl stop kopia_host1_snapshot_@<SNAPSHOT_GROUP>.service
systemctl status kopia_host1_snapshot_@<SNAPSHOT_GROUP>.service

or by specific example

systemctl start kopia_host1_snapshot_@NAS-1-2.service
systemctl start kopia_host1_snapshot_@NAS-1-2-3-4.service
systemctl start kopia_host1_snapshot_@NAS-3-4.service

Given the systemd timer/service is calling my snapshot creation script I can run it directly also using (specific example):

nice -n 19 sudo bash ./kopia_snapshot.sh NAS-1-2-3-4

Description=kopia snapshot %i service
From:
https://www.freedesktop.org/software/systemd/man/systemd.service.html

%I -It is possible for systemd services to take a single argument via the
“service@argument.service” syntax. Such services are called “instantiated”
services, while the unit definition without the argument parameter is called
a “template”. An example could be a dhcpcd@.service service template which
takes a network interface as a parameter to form an instantiated service. In
the service file, this parameter or “instance name” can be accessed with %-specifiers.
See systemd.unit(5) for details.
%i lower case i preserves the escapes

Using linux, my computer wakes from suspend at the timer allocated time, does the backup then goes back into suspend, unless I start using it for other purposes or already using it. So backups happen as long as it is in suspend.

1 Like