emersion / bups

Simple GUI for Bup, a very efficient backup system.
MIT License
95 stars 8 forks source link

Systemd support #4

Closed Edenhofer closed 9 years ago

Edenhofer commented 9 years ago

Since many major linux distributions heavily depend on systemd - if one likes it or not. It is usually preinstalled. Therefore I would suggest to include systemd-timer (https://wiki.archlinux.org/index.php/Systemd/Timers) support for the periodic backups instead or in supplement to anacron.

emersion commented 9 years ago

That would be a good idea :-)

emersion commented 9 years ago

Just added systemd timers support. There is an issue, you cannot control the backup frequency (it's weekly). You'll have to edit the systemd timer manually to change that.

Do you know how to execute a systemd timer each n days?

Edenhofer commented 9 years ago

To achieve this I would use the "OnActiveSec=" option in the [Timer] directive, which defines a monotonic timer relative to the moment the timer itself is activated. By the way I would use hours instead because e.g. I would like to make a snapshot every 2 hours or so. Accordingly using something like this works fine for me:

/etc/systemd/system/bup.timer

[Unit]
Description=Run bup every two hours
[Timer]
OnActiveSec=2hr
[Install]
WantedBy=timers.target

If you want to read more specific information about systemd timers please refer to http://www.freedesktop.org/software/systemd/man/systemd.time.html#Parsing%20Time%20Spans and http://www.freedesktop.org/software/systemd/man/systemd.timer.html And do not forget to trigger a daemon-reload! (https://wiki.archlinux.org/index.php/Systemd)

emersion commented 9 years ago

Thank you!

I have a question: if I set OnActiveSec=7d, the timer will be executed 7 days after it is activated. But what if the computer is shut down? Will it be executed the next time it is powered on?

Edenhofer commented 9 years ago

EDIT: The timer is resetted and the unit will run after 7 Days. Therefore this solution only works for machines which one would never turn off.

emersion commented 9 years ago

Systemd timers are now fully supported.

Concerning backups each 2 hours, for the moment you can edit /etc/systemd/system/bups.timer manually. I've opened a new issue: #5.