1 {lib, stdenv, which, coreutils, perl, fetchurl, makeWrapper, diffutils , writeScriptBin, bzip2}:
4 # storeBackup.pl --sourceDir /home/user --backupDir /tmp/my_backup_destination
5 # Its slow the first time because it compresses all files bigger than 1k (default setting)
6 # The backup tool is bookkeeping which files got compressed
8 # btrfs warning: you may run out of hardlinks soon
10 # known impurity: test cases seem to bu using /tmp/storeBackup.lock ..
12 let dummyMount = writeScriptBin "mount" "#!${stdenv.shell}";
15 stdenv.mkDerivation rec {
19 pname = "store-backup";
21 enableParallelBuilding = true;
23 nativeBuildInputs = [ makeWrapper ];
24 buildInputs = [ perl ];
27 url = "https://download.savannah.gnu.org/releases/storebackup/storeBackup-${version}.tar.bz2";
28 hash = "sha256-Ki1DT2zypFFiiMVd9Y8eSX7T+yr8moWMoALmAexjqWU=";
32 # https://www.openwall.com/lists/oss-security/2020/01/20/3
39 mv $out/_ATTENTION_ $out/doc
40 mv $out/{correct.sh,cron-storebackup} $out/scripts
42 find $out -name "*.pl" | xargs sed -i \
43 -e 's@/bin/pwd@${coreutils}/bin/pwd@' \
44 -e 's@/bin/sync@${coreutils}/bin/sync@' \
45 -e '1 s@/usr/bin/env perl@${perl.withPackages (p: [ p.DBFile ])}/bin/perl@'
48 do wrapProgram "$p" --prefix PATH ":" "${lib.makeBinPath [ which bzip2 ]}"
52 # do a dummy test ensuring this works
54 PATH=$PATH:${dummyMount}/bin
57 export HOME=$(mktemp -d)
58 { # simple sanity test, test backup/restore of simple store paths
65 echo RUNNING TEST "$1" source: "$source"
68 $out/bin/storeBackup.pl --sourceDir "$source" --backupDir backup
69 latestBackup=backup/default/$(ls -1 backup/default | sort | tail -n 1)
70 $out/bin/storeBackupRecover.pl -b "$latestBackup" -t restored -r /
71 ${diffutils}/bin/diff -r "$source" restored
73 # storeBackupCheckSource should return 0
74 $out/bin/storeBackupCheckSource.pl -s "$source" -b "$latestBackup"
75 # storeBackupCheckSource should return not 0 when using different source
76 ! $out/bin/storeBackupCheckSource.pl -s $TMP -b "$latestBackup"
78 # storeBackupCheckBackup should return 0
79 $out/bin/storeBackupCheckBackup.pl -c "$latestBackup"
91 backupRestore 'test 1: backup, restore' $testDir
93 # test huge blocks, according to docs files bigger than 100MB get split
95 dd if=/dev/urandom bs=100M of=block-1 count=1
96 dd if=/dev/urandom bs=100M of=block-2 count=1
97 cat block-1 block-2 > $testDir/block
98 backupRestore 'test 1 with huge block' $testDir
100 cat block-2 block-1 > $testDir/block
101 backupRestore 'test 1 with huge block reversed' $testDir
103 backupRestore 'test 2: backup, restore' $out
104 backupRestore 'test 3: backup, restore' $out
105 backupRestore 'test 4: backup diffutils to same backup locations, restore' ${diffutils}
110 description = "Backup suite that stores files on other disks";
111 homepage = "https://savannah.nongnu.org/projects/storebackup";
112 license = lib.licenses.gpl3Plus;
113 maintainers = [lib.maintainers.marcweber];
114 platforms = lib.platforms.linux;