You are not logged in.
Hi there,
So I've written a little program for managing daily backups in Haskell, which I call 'tarsnapper'. In following the archwiki page https://wiki.archlinux.org/index.php/Systemd/Timers I've tried to assemble a daily backup timer. I've created a file named tarsnapper.service:
[Unit]
Description=Tarsnap backup via Tarsnapper
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
User=alex404
StandardOutput=journal
ExecStart=/home/alex404/.cabal/bin/tarsnapper
and a file tarsnapper.timer
[Unit]
Description=Daily Tarsnapper backup
[Timer]
# see systemd.time(7) manual page for other scheduling options
OnCalendar=daily
# run immediately if we missed a backup for some reason
Persistent=true
[Install]
WantedBy=timers.target
which I've enabled.
Now, the timer runs the service, but the odd thing is that the service does run properly. In particular, I can see that tarsnapper is excuting the commands 'tarsnap --list-archives', but it does not seem to parse the text/respond to it in the usual way. What's especially strange is that if I execute 'sudo systemctl start tarsnapper.service', it will run tarsnapper and have it execute correctly as if I'd simply entered 'tarsnapper' at the command line.
Is there some subtle way in which stdin/out and such are processed differently when I run things in the command line vs have them activated by timers?
Thanks!
Last edited by alex404 (2014-11-01 11:13:56)
Offline
Can you post the script tarsnapper and what it writes in the journal when you start the service manually and when the timer starts it automatically.
Last edited by berbae (2014-10-15 21:30:33)
Offline
Hey, sorry for the slow response. I looked into my journalctl and noticed that rather obvious fact that tarsnapper is failing because it tries to run before my computer has had time to establish an internet connection. I'm going to see if I can fix this in a reasonable way, and then report back my results.
Offline
Okay, just to close this off for anyone having a similar newbie problem, add the lines
Restart=on-failure
RestartSec=600
to the backup.service file to get it to restart every ten minutes until it exits properly. This should be enough for a robust, persistent, daily backup.
Offline
Offline
Hey, sorry for the slow response. I looked into my journalctl and noticed that rather obvious fact that tarsnapper is failing because it tries to run before my computer has had time to establish an internet connection. I'm going to see if I can fix this in a reasonable way, and then report back my results.
Try add this in tarsnapper.service:
[Unit]
Description=Tarsnap backup via Tarsnapper
After=network.target
Last edited by serdotlinecho (2014-11-02 10:53:17)
Offline