simplifying TestBorgRepo

This commit is contained in:
Djan 2022-08-16 09:55:36 +02:00
parent 84cfd59231
commit 12f02051c7
1 changed files with 7 additions and 30 deletions

View File

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