You are not logged in.

#1 2016-01-31 12:41:31

_pheinrich_
Member
Registered: 2014-05-26
Posts: 53

systemd timer start backup and send mail

Hi,

I have successfully set up a systemd.timer to start my backup service.

Now I try to execute my backup script which starts rsync with hardlink feature to create an historical backup.
The script executes fine but I want to get the output via mail.

Using this command in terminal executes fine and logs to stdout and sends the mail.

/bin/bash -c '/usr/local/bin/backup.sh /srv/data/ /srv/backup/Archive/ | tee >(/usr/bin/mail -S sendwait -s "Arch Media Data Backup" myemail@bla.com)'

Using it in a execStart section of the service just logs the stdout to journalctl but does not send an mail.
I do not know why.

Any ideas?

Offline

#2 2016-02-09 06:13:05

nobby
Member
Registered: 2016-01-12
Posts: 12

Re: systemd timer start backup and send mail

How about /usr/bin/tee instead of tee?

You could set LogLevel=debug in /etc/systemd/user.conf

Offline

#3 2016-03-01 17:29:21

chapatt
Member
Registered: 2010-12-23
Posts: 24

Re: systemd timer start backup and send mail

I was recently doing something very similar with a similar error (no mail sent when used in systemd unit), but using sendwait fixed it for me. Make sure your implementation of mail actually implements sendwait--e.g. GNU's mail accepts sendwait for compatibility reasons, but doesn't actually implement it.

Also, I think your use of tee is superfluous. Tee redirects stdin to stdout as well as to a file you specify as an argument. Piping to tee and redirecting its stdout effectively does nothing.

Last edited by chapatt (2016-03-01 18:40:56)

Offline

Board footer

Powered by FluxBB