From 83ced1ad92f591814c675ddca51bfb720b4b3d7b Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Oct 2021 15:11:35 +0200 Subject: add borg backup to experiment --- exp/Makefile | 16 +++++++++++++--- exp/exp.sh | 13 +++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'exp') diff --git a/exp/Makefile b/exp/Makefile index 81a9464..5437785 100644 --- a/exp/Makefile +++ b/exp/Makefile @@ -38,6 +38,7 @@ DNA_4K ?= dna_4k DNA_8K ?= dna_8k NOPACK ?= nopack export GIT_NOPACK ?= $(abspath $(NOPACK)) +export BORG ?= borg export TARGZ ?= targz export REAL ?= real export DIFFS ?= diffs @@ -47,7 +48,7 @@ export GIT_PATH ?= $(abspath git) GITC := git -C $(REPO_PATH) DNADIRS := $(DNA_4K) $(DNA_8K) -DATADIRS := $(DNA_4K) $(DNA_8K) $(DIFFS) $(NOPACK) $(TARGZ) $(REAL) +DATADIRS := $(DNA_4K) $(DNA_8K) $(DIFFS) $(NOPACK) $(BORG) $(TARGZ) $(REAL) SIZEFILES := $(DATADIRS:%=%.size) .PHONY: all exp @@ -75,6 +76,15 @@ $(DNADIRS:%=%.size) $(REAL).size: %.size: %.versions run cut -f1 $$i | paste -sd+ | bc >> $@; \ done +$(BORG).size: $(BORG).versions run + rm -rf $@ + prev=0; for i in $> $@; \ + prev=$$last; \ + done + $(NOPACK).size: $(NOPACK).versions run rm -rf $@ prev=/dev/null; for i in $ $@ -run: $(COMMITS) $(DNA_BACKUP) $(DNA_PARAMS) | printvars $(DATADIRS) $(NOPACK).versions $(REAL).versions +run: $(COMMITS) $(DNA_BACKUP) $(DNA_PARAMS) | printvars $(DATADIRS) $(NOPACK).versions $(BORG).versions $(REAL).versions rm -rf $(DATADIRS:%=%/*) $(DATADIRS:%=%.versions/*) ./exp.sh touch $@ @@ -120,7 +130,7 @@ $(DNA_PARAMS): echo "$(DNA_4K) -c 4096" >> $@ echo "$(DNA_8K) -c 8192" >> $@ -$(DATADIRS) $(NOPACK).versions $(REAL).versions: +$(DATADIRS) $(NOPACK).versions $(BORG).versions $(REAL).versions: mkdir $@ $(DNA_BACKUP): .FORCE diff --git a/exp/exp.sh b/exp/exp.sh index 923c40c..5e2d9be 100755 --- a/exp/exp.sh +++ b/exp/exp.sh @@ -28,6 +28,7 @@ # - TARGZ: the path of the tar.gz dir # - DIFFS: the path of the git diff dir # - REAL: the path of the real size dir +# - BORG: the path to borg dir # - GIT_NOPACK: the path of the git nopack dir log() { @@ -47,6 +48,9 @@ $GITC init --separate-git-dir=$GIT_NOPACK $GITC --git-dir=$GIT_NOPACK config gc.auto 0 set-git-dir $GIT_PATH +# Init borg dir +borg init -e none $BORG + # "empty tree" commit prev="4b825dc642cb6eb9a060e54bf8d69288fbee4904" last=$(tail --lines=1 $COMMITS | cut -f1) @@ -88,6 +92,15 @@ do > $(printf "%s.versions/%05d" $GIT_NOPACK $i) set-git-dir $GIT_PATH + # Create borg backup for this versions + log "create borg backup for this versions" + borg create $BORG::$i $REPO_PATH + find $BORG/data -type f -exec du -ba {} + \ + | cut -f1 \ + | paste -sd+ \ + | bc \ + > $(printf "%s.versions/%05d" $BORG $i) + # Create dna backups for this version cat $DNA_PARAMS | while read name flags do -- cgit v1.2.3