2013-09-01 21:32:40 +02:00
|
|
|
{stdenv, which, coreutils, perl, fetchurl, perlPackages, makeWrapper, diffutils , writeScriptBin, bzip2}:
|
2013-08-31 22:16:22 +02:00
|
|
|
|
|
|
|
# quick usage:
|
|
|
|
# storeBackup.pl --sourceDir /home/user --backupDir /tmp/my_backup_destination
|
|
|
|
# Its slow the first time because it compresses all files bigger than 1k (default setting)
|
|
|
|
# The backup tool is bookkeeping which files got compressed
|
|
|
|
|
|
|
|
# btrfs warning: you may run out of hardlinks soon
|
|
|
|
|
|
|
|
# known impurity: test cases seem to bu using /tmp/storeBackup.lock ..
|
|
|
|
|
2019-01-15 23:41:31 +01:00
|
|
|
let dummyMount = writeScriptBin "mount" "#!${stdenv.shell}";
|
2013-08-31 22:16:22 +02:00
|
|
|
in
|
|
|
|
|
2015-05-17 12:31:57 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2013-08-31 22:16:22 +02:00
|
|
|
|
2015-05-17 12:31:57 +02:00
|
|
|
version = "3.5";
|
|
|
|
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "store-backup";
|
2013-08-31 22:16:22 +02:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
buildInputs = [ perl makeWrapper ];
|
|
|
|
|
|
|
|
src = fetchurl {
|
2018-12-01 18:07:00 +01:00
|
|
|
url = "https://download.savannah.gnu.org/releases/storebackup/storeBackup-${version}.tar.bz2";
|
2015-05-17 12:31:57 +02:00
|
|
|
sha256 = "0y4gzssc93x6y93mjsxm5b5cdh68d7ffa43jf6np7s7c99xxxz78";
|
2013-08-31 22:16:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
installPhase = ''
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/scripts
|
2013-08-31 22:16:22 +02:00
|
|
|
mv * $out
|
|
|
|
mv $out/_ATTENTION_ $out/doc
|
|
|
|
mv $out/{correct.sh,cron-storebackup} $out/scripts
|
|
|
|
|
|
|
|
find $out -name "*.pl" | xargs sed -i \
|
|
|
|
-e 's@/bin/pwd@${coreutils}/bin/pwd@' \
|
|
|
|
-e 's@/bin/sync@${coreutils}/bin/sync@' \
|
|
|
|
-e '1 s@/usr/bin/env perl@${perl}/bin/perl@'
|
|
|
|
|
|
|
|
for p in $out/bin/*
|
|
|
|
do wrapProgram "$p" \
|
2018-12-15 04:50:31 +01:00
|
|
|
--prefix PERL5LIB ":" "${perlPackages.DBFile}/${perlPackages.perl.libPrefix}" \
|
2016-08-23 00:06:51 +02:00
|
|
|
--prefix PATH ":" "${stdenv.lib.makeBinPath [ which bzip2 ]}"
|
2013-08-31 22:16:22 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
patchShebangs $out
|
|
|
|
# do a dummy test ensuring this works
|
|
|
|
|
|
|
|
PATH=$PATH:${dummyMount}/bin
|
|
|
|
|
|
|
|
|
2013-09-01 21:32:40 +02:00
|
|
|
{ # simple sanity test, test backup/restore of simple store paths
|
|
|
|
|
2013-08-31 22:16:22 +02:00
|
|
|
mkdir backup
|
|
|
|
|
2013-09-01 21:32:40 +02:00
|
|
|
backupRestore(){
|
|
|
|
source="$2"
|
|
|
|
echo =========
|
|
|
|
echo RUNNING TEST "$1" source: "$source"
|
|
|
|
mkdir restored
|
|
|
|
|
|
|
|
$out/bin/storeBackup.pl --sourceDir "$source" --backupDir backup
|
|
|
|
latestBackup=backup/default/$(ls -1 backup/default | sort | tail -n 1)
|
|
|
|
$out/bin/storeBackupRecover.pl -b "$latestBackup" -t restored -r /
|
|
|
|
${diffutils}/bin/diff -r "$source" restored
|
|
|
|
|
|
|
|
# storeBackupCheckSource should return 0
|
|
|
|
$out/bin/storeBackupCheckSource.pl -s "$source" -b "$latestBackup"
|
|
|
|
# storeBackupCheckSource should return not 0 when using different source
|
|
|
|
! $out/bin/storeBackupCheckSource.pl -s $TMP -b "$latestBackup"
|
2013-09-01 02:22:01 +02:00
|
|
|
|
2013-09-01 21:32:40 +02:00
|
|
|
# storeBackupCheckBackup should return 0
|
|
|
|
$out/bin/storeBackupCheckBackup.pl -c "$latestBackup"
|
|
|
|
|
|
|
|
chmod -R +w restored
|
|
|
|
rm -fr restored
|
|
|
|
}
|
|
|
|
|
|
|
|
testDir=$TMP/testDir
|
|
|
|
|
|
|
|
mkdir $testDir
|
|
|
|
echo X > $testDir/X
|
|
|
|
ln -s ./X $testDir/Y
|
|
|
|
|
|
|
|
backupRestore 'test 1: backup, restore' $testDir
|
|
|
|
|
|
|
|
# test huge blocks, according to docs files bigger than 100MB get split
|
|
|
|
# into pieces
|
|
|
|
dd if=/dev/urandom bs=100M of=block-1 count=1
|
|
|
|
dd if=/dev/urandom bs=100M of=block-2 count=1
|
|
|
|
cat block-1 block-2 > $testDir/block
|
|
|
|
backupRestore 'test 1 with huge block' $testDir
|
|
|
|
|
|
|
|
cat block-2 block-1 > $testDir/block
|
|
|
|
backupRestore 'test 1 with huge block reversed' $testDir
|
|
|
|
|
|
|
|
backupRestore 'test 2: backup, restore' $out
|
|
|
|
backupRestore 'test 3: backup, restore' $out
|
|
|
|
backupRestore 'test 4: backup diffutils to same backup locations, restore' ${diffutils}
|
|
|
|
}
|
|
|
|
'';
|
2013-08-31 22:16:22 +02:00
|
|
|
|
|
|
|
meta = {
|
2015-04-30 17:05:14 +02:00
|
|
|
description = "A backup suite that stores files on other disks";
|
2018-12-01 18:32:32 +01:00
|
|
|
homepage = https://savannah.nongnu.org/projects/storebackup;
|
2013-08-31 22:16:22 +02:00
|
|
|
license = stdenv.lib.licenses.gpl3Plus;
|
|
|
|
maintainers = [stdenv.lib.maintainers.marcweber];
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
};
|
|
|
|
}
|