baodrate / snap-sync

Use snapper snapshots to backup to external drive
GNU General Public License v2.0
130 stars 38 forks source link

Remove | tee $PIPE and systemd-cat #103

Open wesbarnett opened 3 years ago

wesbarnett commented 3 years ago

Remove duplication of logs.

Fixes #101.

NicoHood commented 3 years ago

Well, this looks trivial. Why was $PIPE even used?

I found this: https://github.com/wesbarnett/snap-sync/commit/e7085c4f92956290638739677e03837d144781dd

I am not sure what the issue is here, is it only to print to stderr? https://stackoverflow.com/questions/10963653/what-method-should-i-use-to-write-error-messages-to-stderr-using-printf-in-a

wesbarnett commented 3 years ago

They problem I was trying to solve was getting the output to print both to the screen and to the systemd journal, since this can be set to run with a systemd unit.

This sets up $PIPE here: https://github.com/wesbarnett/snap-sync/blob/master/bin/snap-sync#L41-L43

But, after some searching I think the correct way is to print to stdout/stderr without setting up systemd-cat and then in the systemd unit specify StandardOutput=journal+console

wesbarnett commented 3 years ago

Now it looks like it's not even necessary any more. It looks like the stdout automatically goes to the systemd journal for the unit

The StandardOutput entry for man systemd.exec says:

This setting defaults to the value set with DefaultStandardOutput= in systemd-system.conf(5), which defaults to journal.

So, yep this was all unnecessary to begin with. Will update PR

NicoHood commented 3 years ago

That is weird. But didnt you introduce that feature because it did not work before? Why does it work now?

Looks way cleaner though :-)