Skip to content

Instantly share code, notes, and snippets.

@EthraZa EthraZa/backmark.sh
Created Oct 27, 2017

Embed
What would you like to do?
Backmark.sh Will create a pool of binary and text files with random content, duplicate then in two directories and backup it twice with multiple tools to compare their time and size.
#!/bin/bash
##
# Backmark.sh
#
# Will create a pool of binary and text files with random content,
# duplicate then in two directories and backup it twice
# with multiple tools to compare their time and size.
#
# Simple like that.
##
# Configs
# How many
GEN_TXT=1000
GEN_BIN=1000
FILES_MIN_SIZE=1024
# What to do
DEL_POOL=1
DEL_BKPS=1
TARGZ=1
RSYNC=1
BORG=1
# Good stuff
echo 3 | sudo tee /proc/sys/vm/drop_caches &>/dev/null
printf "\n### Start Backmark \n"
mkdir POOL &> /dev/null
for r in {1..2}; do
printf "\n## Backmark run ${r} \n"
mkdir -p POOL/${r}/a &> /dev/null
mkdir -p POOL/${r}/b &> /dev/null
if [ ${GEN_TXT} -gt 0 ]; then
printf "# POOL of TXTs ${r} \n"
for n in $(eval echo {1..$GEN_TXT}); do
fn=file_$( printf %03d "${n}" ).txt
base64 /dev/urandom | head -c $(( RANDOM + ${FILES_MIN_SIZE} )) |tee POOL/${r}/a/${fn} POOL/${r}/b/${fn} &>/dev/null
done
fi
if [ ${GEN_BIN} -gt 0 ]; then
printf "# POOL of BINs ${r} \n"
for n in $(eval echo {1..${GEN_BIN}}); do
fn=file_$( printf %03d "${n}" ).bin
cat /dev/urandom | head -c $(( RANDOM + ${FILES_MIN_SIZE} )) |tee POOL/${r}/a/${fn} POOL/${r}/b/${fn} &>/dev/null
done
fi
du -sh POOL
if [ ${TARGZ} -gt 0 ]; then
printf "\n# TARGZ Backup ${r}\n"
mkdir TARGZ &>/dev/null
\time -f "real %e \nuser %U \nsys %S \nio %w" tar -czf TARGZ/backmark.tgz -g TARGZ/targz.snar POOL >/dev/null
du -sh TARGZ
fi
if [ ${RSYNC} -gt 0 ]; then
printf "\n# RSYNC Backup ${r}\n"
mkdir RSYNC &> /dev/null
\time -f "real %e \nuser %U \nsys %S \nio %w" rsync -aR --progress POOL RSYNC >/dev/null
du -sh RSYNC
fi
if [ ${BORG} -gt 0 ]; then
printf "\n# BORG Backup ${r}\n"
mkdir BORG &> /dev/null
borg init --encryption=none BORG &>/dev/null
\time -f "real %e \nuser %U \nsys %S \nio %w" borg create --compression lz4,9 --progress BORG::R${r} POOL >/dev/null
du -sh BORG
fi
done
if [ ${DEL_POOL} -gt 0 ]; then
rm -rf POOL
fi
if [ ${DEL_BKPS} -gt 0 ]; then
rm -rf TARGZ RSYNC BORG
fi
printf "\n### End Backmark \n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.