The Other Side

To finish off my move from cron to systemd timers, I had one left which ran as my normal user on my home machine to download the prepared backup file, check it, then delete it from the server. All of this part was done as a normal user, no sudo, and nothing as root.

Set up env, as per 2.1:
“The user instance of systemd does not inherit any of the environment variables set in places like .bashrc etc.”
env > ~/.config/environment.d/.conf
vi ~/.config/environment.d/.conf

Clean up unneeded lines in the above config. If you aren’t sure, it is probably safe to leave it.

Create your service:
vi ~/.config/systemd/user/receivebackups.service
cat ~/.config/systemd/user/receivebackups.service
Description=Run receive WordPress backup script

Check crontab to match times (my localtime is America/New_York):
crontab -l
30 03 * * 0 /home/marshall/

Create the timer unit:
vi ~/.config/systemd/user/receivebackups.timer
cat ~/.config/systemd/user/receivebackups.timer
Description=Run webbackups script weekly
OnCalendar=Sun *-*-* 08:30:00 UTC

Enable and start the timer:
systemctl –user enable receivebackups.timer
systemctl –user start receivebackups.timer
systemctl –user list-timers
Sun 2022-11-06 03:30:00 EST 3 days left Mon 2022-10-31 21:13:11 EDT 2 days ago receivebackups.timer receivebackups.service

Finally, if you intend on the timer running without your user being logged in, follow 2.2:
loginctl enable-linger marshall

And for completeness, I will include my sanitized script:
cat ~/
for x in ssh root@server ls /backups/; do
scp root@server:/backups/$x /storage/webbackups
tar ztvf /storage/webbackups/$x > /dev/null &&
ssh root@server rm /backups/$x

My notes for future me