Backup using systemd timers

Hi all,
I am using systemd-timers to start a bash script which updates my data to a Nas, and to a USB drive. Since I use Kinoite (again) I can’t get this to work as I want it to work. It does start the backup at the correct time and all, but also does that when I boot, or maybe better when I log in. This is not necessary.
I have the following files and their contents:
-rw-rw-r--. 1 user user 138 28 okt 12:24 Backup.service

cat Backup.service
[Unit]
Description="Backup data from internal HDD to Nas"

[Service]
ExecStart=/home/user/bin/Backup.sh

[Install]
WantedBy=default.target

and
-rw-rw-r--. 1 user user 179 28 okt 13:41 Backup.timer

cat Backup.timer 
[Unit]
Description="Backup data from internal HDD to Nas"
After=multi-user.target

[Timer]
OnCalendar=21:30
Persistent=true
Unit=Backup.service

[Install]
WantedBy=timers.target

And I have a script which does the actual backup using rsync. This all works.

As said the backup script is started at the programmed time (21.30) but also at log-in.
What do I have to change to make it stop doing that? I have been all over the internet to find help and I found a 1001 different versions of the 2 files, all without a clear explanation what the codes in the files really do. I’m guessing it has to do with the After=, WantedBy= codes, but can’t figure out what they mean and do.

Who can help me?

Disable the Backup.service and remove its [Install] section.

1 Like

And as you expected, this works. As I wrote I saw so many different files, all with other contents. I was just now reading, or better tying to read the man pages about systemd.timers and this made it even more complicated.
Thanks @vgaetera , now it only starts the backup at the programmed time.

1 Like

You might also want to remove Persistent=true if you never want your script to run outside of the scheduled time. See man systemd.timer for the explanation of what it does.

2 Likes

Thanks Gregory, I already removed it after I started this thread. Yes, I know what it does, and the programmed time the backup should start is what I want.