adding index functions
- bobaindexgeneratelist - bobaindexsearch - bobaindexumount
This commit is contained in:
parent
df298d0542
commit
36468bc88f
@ -85,11 +85,15 @@ 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
|
||||
}
|
||||
|
||||
@ -206,6 +210,61 @@ function bobadur {
|
||||
done
|
||||
}
|
||||
|
||||
function bobaindexgeneratelist {
|
||||
TestBorgRepo
|
||||
echo "Warning, list of file will be generating OUTSIDE the repo,so it will be in CLEARTEXT."
|
||||
echo "This could be a securty issue, as it will expose file list of all archives."
|
||||
echo "Generating list could last a very long time and take some disk space."
|
||||
read -p "Continue ? [N/y] " CONT
|
||||
if [ "$CONT" != "y" ];then
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Generating list..."
|
||||
indexdir=bobaindex_$(date +%Y%m%d)
|
||||
mkdir -p $indexdir
|
||||
|
||||
for archive in $(borg list --short ./);do
|
||||
echo "Generating list for $archive"
|
||||
borg list --short .::"$archive" >> $indexdir/"$archive"
|
||||
done
|
||||
|
||||
echo "Adding index to repo..."
|
||||
borg create .::bobaindex_$(date +%Y%m%d) $indexdir/
|
||||
rm -rf $indexdir/
|
||||
echo "Borg index generated."
|
||||
}
|
||||
|
||||
function bobaindexsearch {
|
||||
TestBorgRepo
|
||||
indexarchive=$(borg list --short . | grep bobaindex | head -n 1)
|
||||
|
||||
if [ "$1" = "" ];then
|
||||
echo "No argument.";return
|
||||
fi
|
||||
|
||||
if [ $indexarchive = "" ];then
|
||||
echo "bobaindex not found";return
|
||||
fi
|
||||
|
||||
if [ ! -d $HOME/$indexarchive ];then
|
||||
echo "Mounting index..."
|
||||
mkdir $HOME/$indexarchive
|
||||
borg mount ./::$indexarchive $HOME/$indexarchive
|
||||
fi
|
||||
|
||||
cd $HOME/$indexarchive
|
||||
grep -i -r $1 ./
|
||||
cd -
|
||||
}
|
||||
|
||||
function bobaindexumount {
|
||||
mountpoint=$(findmnt -l --output TARGET | grep bobaindex)
|
||||
fusermount -u -z "$mountpoint"
|
||||
sleep 5
|
||||
rmdir "$mountpoint"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# mount functions
|
||||
###############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user