%global _hardened_build 1 Name: snebu Version: 1.1.2 Release: 1%{?dist} Group: Applications/System License: GPLv3 URL: https://www.snebu.com Source0: https://github.com/derekp7/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz Source1: %{name}.sysusers Requires: lzop BuildRequires: lzo-devel openssl-devel sqlite-devel gcc make systemd-rpm-macros systemd Summary: Simple Network Encrypting Backup Utility %package client Summary: Client script and encryption utility for Snebu %description Snebu is a backup utility which is designed to be easy to setup and use, yet provide many features that are usually only found on high-end backup programs. Features a client-server architecture built around standard tools (find, tar, ssh), file-level deduplication and compression, optional encryption, granular user permissions and a backup catalog stored in an SQLite database file. %description client The snebu-client package contains a front-end shell script, snebu-client, along with an encryption module, tarcrypt, for use with the snebu backup system. %prep %autosetup %build %set_build_flags %make_build %install mkdir -p %{buildroot}%_bindir env %make_install PREFIX=%{_prefix} rm -rf %{buildroot}%{_docdir}/%{name} mkdir -p %{buildroot}%{?_localstatedir}/lib/%{name} install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/%{name}.conf %check # Test setup echo "" configpath=%{_builddir}/snebu-tests.conf datadir=%{_builddir}/snebu-tests.data cat <${configpath} vault=${datadir}/vault meta=${datadir}/catalog EOT bkdate=$(date +%s) bkdate2=$((bkdate + 86400)) includetemp=$(mktemp /tmp/snebu.include.XXXXXXXXXX) filelisttemp=$(mktemp /tmp/snebu.filelist.XXXXXXXXXX) filelisttemp2=$(mktemp /tmp/snebu.filelist.XXXXXXXXXX) testfailed() { echo "$1" exit 1 } echo "test file ${bkdate}" >testfile_${bkdate} # Test Back up build directory echo "Testing backup process using build directory" ## Prep manifest find %{_builddir} -xdev -path ${datadir} -prune -o \( -type f -o -type d \) \ -printf "%y\t%#m\t%D\t%i\t%u\t%U\t%g\t%G\t%s\t0\t%C@\t%T@\t%p\0" -o -type l \ -printf "%y\t%#m\t%D\t%i\t%u\t%U\t%g\t%G\t%s\t0\t%C@\t%T@\t%p\0%l\0" |\ ./snebu -c ${configpath} newbackup --name testbk1 --retention daily \ --datestamp ${bkdate} --null --not-null-output -v >${includetemp} ## Send files tar --one-file-system --no-recursion -S -P -T ${includetemp} -cf - |\ ./snebu -c ${configpath} submitfiles --name testbk1 --datestamp ${bkdate} || \ testfailed "Failed test backup testbk1" echo "Test passed" echo "" # List backup files echo "Listing backup files" ./snebu -c ${configpath} listbackups --name testbk1 --datestamp ${bkdate} |\ tee ${filelisttemp} grep testfile_${bkdate} ${filelisttemp} || \ testfailed "Failed test listbackups testbk1" echo "Test passed" echo "" # Run restore verification test echo "Running restore verification test" ./snebu -c ${configpath} restore --name testbk1 --datestamp ${bkdate} |\ tar -C / -df - || \ testfailed echo "Failed test restore validation testbk1" echo "Test passed" echo "" # Do a second backup with a file removed and a new file echo "Running second backup test" rm testfile_${bkdate} echo "test file 2${bkdate2}" >testfile_${bkdate2} ## Prep manifest find %{_builddir} -xdev -path ${datadir} -prune -o \( -type f -o -type d \) \ -printf "%y\t%#m\t%D\t%i\t%u\t%U\t%g\t%G\t%s\t0\t%C@\t%T@\t%p\0" -o -type l \ -printf "%y\t%#m\t%D\t%i\t%u\t%U\t%g\t%G\t%s\t0\t%C@\t%T@\t%p\0%l\0" |\ ./snebu -c ${configpath} newbackup --name testbk1 --retention daily \ --datestamp ${bkdate2} --null --not-null-output -v >${includetemp} ## Send files tar --one-file-system --no-recursion -S -P -T ${includetemp} -cf - |\ ./snebu -c ${configpath} submitfiles --name testbk1 --datestamp ${bkdate2} || \ testfailed "Failed test backup testbk1" echo "Test passed" echo "" # List backup files echo "Listing backup files" ./snebu -c ${configpath} listbackups --name testbk1 --datestamp ${bkdate2} |\ tee ${filelisttemp2} grep testfile_${bkdate2} ${filelisttemp2} || \ testfailed "Failed test listbackups testbk1" echo "Test passed" echo "" # Run restore verification test echo "Running restore verification test" ./snebu -c ${configpath} restore --name testbk1 --datestamp ${bkdate2} |\ tar -C / -df - || \ testfailed echo "Failed test restore validation testbk1" echo "Test passed" echo "" # Test expiring backup echo "Testing backup expiration" ./snebu -c ${configpath} expire -n testbk1 --datestamp ${bkdate} || testfailed "Failed test exipre ${bkdate} from testbk1" echo "Test passed" echo "" # Make sure testfile from bkdate2 is still present in backup 2 echo "Testing if contents of second test file is still present" ./snebu -c ${configpath} restore --name testbk1 --datestamp ${bkdate2} |\ tar -C / --to-stdout -xf - "*testfile_${bkdate2}" |grep "test file 2${bkdate2}" || \ testfailed "Failed test find \"test file 2\" contents from \"testfile_${bkdate2}\" in backup ${bkdate2}" echo "Test passed" echo "" sleep 5 # Run a purge test echo "Testing if purge removes backend files from first backup" filecount1=$(find ${datadir}/vault -type f |wc -l) ./snebu -c ${configpath} purge filecount2=$(find ${datadir}/vault -type f |wc -l) if [ "${filecount2}" -ge "${filecount1}" ] then testfailed "Failed purge -- ${filecount2} should be less than ${filecount1}" fi echo "Test passed" echo "" exit 0 %pre %sysusers_create_compat %{SOURCE1} %files %config(noreplace) %_sysconfdir/%{name}.conf %attr(6755, snebu, snebu) %_bindir/%{name} %doc docs/readme.md %doc docs/snebu*.adoc %{!?_licensedir:%global license %%doc} %license COPYING.txt %{_mandir}/man1/snebu.1.gz %{_mandir}/man1/snebu-expire.1.gz %{_mandir}/man1/snebu-listbackups.1.gz %{_mandir}/man1/snebu-newbackup.1.gz %{_mandir}/man1/snebu-permissions.1.gz %{_mandir}/man1/snebu-purge.1.gz %{_mandir}/man1/snebu-restore.1.gz %{_mandir}/man1/snebu-submitfiles.1.gz %dir %attr(0700, snebu, snebu) %dir %{?_localstatedir}/lib/%{name} %{_sysusersdir}/snebu.conf %files client %{_bindir}/snebu-client %{_bindir}/tarcrypt %{_mandir}/man1/snebu-client.1.gz %{_mandir}/man1/snebu-client-backup.1.gz %{_mandir}/man1/snebu-client-listbackups.1.gz %{_mandir}/man1/snebu-client-restore.1.gz %{_mandir}/man1/snebu-client-validate.1.gz %{_mandir}/man1/tarcrypt.1.gz %{_mandir}/man5/snebu-client.conf.5.gz %{_mandir}/man5/snebu-client-plugin.5.gz %{!?_licensedir:%global license %%doc} %license COPYING.txt %changelog * Tue Jan 5 2021 Derek Pressnall - 1.1.2-1 - Updated to release 1.1.2 - Added test cases to spec file * Tue Dec 29 2020 Derek Pressnall - 1.1.1-1 - Updated to release 1.1.1 * Sat Dec 26 2020 Derek Pressnall - 1.1.0-1 - Updated to release 1.1.0 - Upstream switched to semantic versioning * Mon Sep 9 2019 Derek Pressnall - 1.04-1 - Updated to release 1.04