From d2b3ffaab99b077329c5281afd54af614483a6d1 Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Tue, 24 May 2022 17:42:02 +0200 Subject: [PATCH] update restic to v0.13.1 and add backup scripts --- SOURCES/restic-excludes.txt | 9 +++++++++ SOURCES/restic-itix-backup | 13 +++++++++++++ SOURCES/restic.conf | 8 ++++++++ SOURCES/restic.service | 5 +++++ SOURCES/restic.timer | 9 +++++++++ SPECS/restic.spec | 34 ++++++++++++++++++++++++++++++---- 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 SOURCES/restic-excludes.txt create mode 100644 SOURCES/restic-itix-backup create mode 100644 SOURCES/restic.conf create mode 100644 SOURCES/restic.service create mode 100644 SOURCES/restic.timer diff --git a/SOURCES/restic-excludes.txt b/SOURCES/restic-excludes.txt new file mode 100644 index 0000000..6b873aa --- /dev/null +++ b/SOURCES/restic-excludes.txt @@ -0,0 +1,9 @@ +lost+found +.DS_Store +thumbs.db +/var/restic +/proc +/sys +/dev +/run +/tmp diff --git a/SOURCES/restic-itix-backup b/SOURCES/restic-itix-backup new file mode 100644 index 0000000..a09167a --- /dev/null +++ b/SOURCES/restic-itix-backup @@ -0,0 +1,13 @@ +#!/bin/bash + +set -Eeuo pipefail + +export PATH="/opt/restic/bin:$PATH" +. /opt/restic/etc/restic.conf + +if [ -f /opt/restic/etc/excludes.txt ]; then + RESTIC_OPTIONS+=("--exclude-file=/opt/restic/etc/excludes.txt") +fi + +echo "Starting a backup..." +restic backup "${RESTIC_OPTIONS[@]}" "${RESTIC_TARGETS[@]}" "$@" diff --git a/SOURCES/restic.conf b/SOURCES/restic.conf new file mode 100644 index 0000000..728415e --- /dev/null +++ b/SOURCES/restic.conf @@ -0,0 +1,8 @@ +export B2_ACCOUNT_ID='backblaze key id' +export B2_ACCOUNT_KEY='backblaze key secret' +export RESTIC_REPOSITORY='backblaze repo' +export RESTIC_PASSWORD_FILE=/opt/restic/etc/restic.key +export RESTIC_CACHE_DIR=/srv/restic/cache/ +export TMPDIR=/srv/restic/tmp/ +RESTIC_TARGETS=("/") +RESTIC_OPTIONS=() diff --git a/SOURCES/restic.service b/SOURCES/restic.service new file mode 100644 index 0000000..6449c11 --- /dev/null +++ b/SOURCES/restic.service @@ -0,0 +1,5 @@ +[Unit] +Description=Run a backup + +[Service] +ExecStart=/opt/restic/bin/itix-backup diff --git a/SOURCES/restic.timer b/SOURCES/restic.timer new file mode 100644 index 0000000..8556423 --- /dev/null +++ b/SOURCES/restic.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Schedule a periodic backup + +[Timer] +OnBootSec=1h +OnUnitActiveSec=1d + +[Install] +WantedBy=timers.target diff --git a/SPECS/restic.spec b/SPECS/restic.spec index bfd5d22..277311e 100644 --- a/SPECS/restic.spec +++ b/SPECS/restic.spec @@ -1,9 +1,15 @@ Name: restic -Version: 0.12.0 +Version: 0.13.1 Release: itix1 Summary: Fast, secure, efficient backup program License: BSD Source0: https://github.com/restic/%{name}/releases/download/v%{version}/%{name}_%{version}_linux_amd64.bz2 +Source1: restic-excludes.txt +Source2: restic.conf +Source3: restic.service +Source4: restic.timer +Source5: restic-itix-backup +BuildRequires: systemd ExclusiveArch: x86_64 %description @@ -20,16 +26,36 @@ three major operating systems (Linux, macOS, Windows) and a few smaller ones %prep %setup -q -c -T bunzip2 -c %{S:0} > restic +cp %{S:1} excludes.txt +cp %{S:2} restic.conf +cp %{S:3} restic.service +cp %{S:4} restic.timer +cp %{S:5} itix-backup %build %install -install -D restic %{buildroot}/opt/restic/bin/restic +install -m 0755 -D restic %{buildroot}/opt/restic/bin/restic +install -m 0600 -D restic.conf %{buildroot}/opt/restic/etc/restic.conf +install -m 0644 -D excludes.txt %{buildroot}/opt/restic/etc/excludes.txt +install -m 0755 -D itix-backup %{buildroot}/opt/restic/bin/itix-backup +install -m 0700 -d %{buildroot}/srv/restic +install -m 0700 -d %{buildroot}/srv/restic/tmp +install -m 0700 -d %{buildroot}/srv/restic/cache +install -m 0644 -D restic.service %{buildroot}/%{_unitdir}/restic.service +install -m 0644 -D restic.timer %{buildroot}/%{_unitdir}/restic.timer %files %defattr(0644, root, root, 0755) %attr(0755, root, root) /opt/restic/bin/restic +%attr(0755, root, root) /opt/restic/bin/itix-backup +/opt/restic/etc +%config(noreplace) %attr(0600, root, root) /opt/restic/etc/restic.conf +%config(noreplace) /opt/restic/etc/excludes.txt +%attr(0700, root, root) /srv/restic +%attr(0700, root, root) /srv/restic/tmp +%attr(0700, root, root) /srv/restic/cache +%{_unitdir}/restic.service +%{_unitdir}/restic.timer %changelog -* Mon Feb 22 2021 Nicolas MASSE - 0.12.0-itix1 -- First release