simplifying TestBorgRepo

This commit is contained in:
Djan 2022-08-16 09:55:36 +02:00
parent 84cfd59231
commit 12f02051c7

View File

@ -86,16 +86,17 @@ alias bobahelp="bobaman"
function TestBorgRepo { function TestBorgRepo {
if [ ! -f "config" ]; then if [ ! -f "config" ]; then
TestBorgErr=1 TestBorgErr=1
echo "Unable to find borgbackup repo config file."
sleep 3
exit
fi fi
if [ ! -d "data" ]; then if [ ! -d "data" ]; then
TestBorgErr=1 TestBorgErr=1
echo "Unable to find borgbackup data folder." fi
sleep 3
exit if [ "$TestBorgErr" = "1" ];then
echo "Not in a borg repo."
echo "Exiting in 5 seconds."
sleep 5
return
fi fi
} }
@ -127,42 +128,36 @@ function bobapassphrase {
function bobals { function bobals {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg list --short ./ borg list --short ./
} }
function bobalstimes { function bobalstimes {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg list --format {barchive}{SPACE}{SPACE}{TAB}{start}{NL} ./ borg list --format {barchive}{SPACE}{SPACE}{TAB}{start}{NL} ./
} }
function bobagrepls { function bobagrepls {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg list --short ./ | grep $1 borg list --short ./ | grep $1
} }
function bobainfoa { function bobainfoa {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg info ./::$1 borg info ./::$1
} }
function bobainfor { function bobainfor {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg info ./ borg info ./
} }
function bobainfolast { function bobainfolast {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
archive=$(borg list --short ./ | tail -n 1) archive=$(borg list --short ./ | tail -n 1)
borg info .::"$archive" borg info .::"$archive"
@ -170,7 +165,6 @@ function bobainfolast {
function bobainfotail { function bobainfotail {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
for archive in $(borg list --short ./ | tail -n 5);do for archive in $(borg list --short ./ | tail -n 5);do
echo "----------------------------------------------------" echo "----------------------------------------------------"
@ -181,7 +175,6 @@ function bobainfotail {
function bobainfoall { function bobainfoall {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
@ -192,7 +185,6 @@ function bobainfoall {
function bobadurationr { function bobadurationr {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
borg info .::$borgarchive | grep "Archive name" borg info .::$borgarchive | grep "Archive name"
@ -203,7 +195,6 @@ function bobadurationr {
function bobadur { function bobadur {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ];then return;fi
echo " Original size Compressed size Deduplicated size" echo " Original size Compressed size Deduplicated size"
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
@ -273,7 +264,6 @@ function bobaindexumount {
function bobamount { function bobamount {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
mountpoint="$HOME/borg_$1" mountpoint="$HOME/borg_$1"
mkdir $mountpoint mkdir $mountpoint
@ -285,7 +275,6 @@ function bobamount {
function bobamountfirst { function bobamountfirst {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
archive=$(borg list ./ --short | head -n 1) archive=$(borg list ./ --short | head -n 1)
mountpoint="$HOME/borg_$archive" mountpoint="$HOME/borg_$archive"
@ -298,7 +287,6 @@ function bobamountfirst {
function bobamountlast { function bobamountlast {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
archive="$(borg list ./ --short | tail -n 1)" archive="$(borg list ./ --short | tail -n 1)"
mountpoint="$HOME/borg_$archive" mountpoint="$HOME/borg_$archive"
@ -316,7 +304,6 @@ function bobamountlast {
function bobasearchinrepo { function bobasearchinrepo {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
for borgarchive in $(borg list --short ./);do for borgarchive in $(borg list --short ./);do
borggrep=$(borg list --short .::$borgarchive | grep -i $1) borggrep=$(borg list --short .::$borgarchive | grep -i $1)
@ -331,7 +318,6 @@ function bobasearchinrepo {
function bobasearchinarchive { function bobasearchinarchive {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg list --short .::"$1" | grep -i "$2" borg list --short .::"$1" | grep -i "$2"
} }
@ -339,7 +325,6 @@ function bobasearchinarchive {
function bobacachedel { function bobacachedel {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ];then return;fi
repoid=$(cat config | grep id | cut -f3 -d" ") repoid=$(cat config | grep id | cut -f3 -d" ")
echo "Repo ID : "$repoid;sleep 5 echo "Repo ID : "$repoid;sleep 5
@ -349,7 +334,6 @@ function bobacachedel {
function bobasecuritydel { function bobasecuritydel {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ];then return;fi
repoid=$(cat config | grep id | cut -f3 -d" ") repoid=$(cat config | grep id | cut -f3 -d" ")
echo "Repo ID : "$repoid;sleep 5 echo "Repo ID : "$repoid;sleep 5
@ -363,14 +347,12 @@ function bobasecuritydel {
function bobadel { function bobadel {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borg delete ./::$1 borg delete ./::$1
} }
function bobadelast { function bobadelast {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
archive=$(borg list ./ --short | tail -n 1) archive=$(borg list ./ --short | tail -n 1)
borg delete .::$archive borg delete .::$archive
@ -378,7 +360,6 @@ function bobadelast {
function bobacheckrepo { function bobacheckrepo {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
borg check -v . borg check -v .
@ -391,7 +372,6 @@ function bobacheckrepo {
function bobadeleter { function bobadeleter {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
file="borgdelete_$borgrepo.sh" file="borgdelete_$borgrepo.sh"
@ -427,7 +407,6 @@ function bobadeleter {
function bobagrepdeleter { function bobagrepdeleter {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
file="borgdelete_$borgrepo.sh" file="borgdelete_$borgrepo.sh"
@ -454,7 +433,6 @@ function bobagrepdeleter {
# mass archive renaming # mass archive renaming
function bobarenamer { function bobarenamer {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
which paste || echo "Paste command not found." exit which paste || echo "Paste command not found." exit
borgrepo="${PWD##*/}" borgrepo="${PWD##*/}"
@ -495,7 +473,6 @@ function bobarenamer {
function bobaextractallfiles { function bobaextractallfiles {
TestBorgRepo TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
export BORG_REPO=$(echo $PWD) export BORG_REPO=$(echo $PWD)
export BorgName=$(echo ${PWD##*/}) export BorgName=$(echo ${PWD##*/})
mkdir -p $HOME/BorgExtract_"$BorgName"/;cd $HOME/BorgExtract_"$BorgName" mkdir -p $HOME/BorgExtract_"$BorgName"/;cd $HOME/BorgExtract_"$BorgName"