Name:           restic-systemd
Version:        0
%global commit   6216a87fdd1a7b1cbe03e721cd925bdabe2b5ffd
Release:        0.2.git.4.45322d4
Summary:        systemd services and timers for restic

License:        MIT
URL:            https://git.sr.ht/~ananth/restic-systemd
Source0:        https://git.sr.ht/~ananth/restic-systemd/archive/%{commit}.tar.gz#/%{name}-%{commit}.tar.gz
Patch0001:      0001-Fix-name-of-backup-service.patch

BuildArch:      noarch

BuildRequires:  systemd-rpm-macros

%description
Systemd units for backing up to restic repositories on a schedule.

%prep
%autosetup -n %{name}-%{commit}

%install
install -dpm 0755 %{buildroot}%{_unitdir}
install -pm 0644 restic-{backup,prune}@.service %{buildroot}%{_unitdir}
install -pm 0644 restic-{backup,prune}@.timer %{buildroot}%{_unitdir}

%post
%systemd_post 'restic-backup@*.timer' 'restic-prune@*.timer'

%preun
%systemd_preun 'restic-backup@*.timer' 'restic-prune@*.timer'

%postun
%systemd_postun_with_restart 'restic-backup@*.timer' 'restic-prune@*.timer'

%files
%doc README.md config.template
%license LICENSE
%{_unitdir}/restic-*.service
%{_unitdir}/restic-*.timer

%changelog