2022-04-25 18:25:07 +02:00
|
|
|
|
##############################################################################
|
2021-04-05 11:18:32 +02:00
|
|
|
|
# help functions
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobaman() {
|
2021-04-05 11:18:32 +02:00
|
|
|
|
cat << EOF
|
|
|
|
|
BorgBackup alias and functions (by Djan GICQUEL)
|
|
|
|
|
---
|
2021-10-24 15:46:39 +02:00
|
|
|
|
bobals With argument, list all files of an archive/Without argument, list archives in repo
|
2021-08-08 09:14:56 +02:00
|
|
|
|
bobagrepls List the archives of the repository with a filter as argument
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobainfoa Get information of an archive in argument
|
|
|
|
|
bobainfor Get information of a repository
|
|
|
|
|
bobainfolast Get info from last archive
|
2023-09-18 13:14:02 +02:00
|
|
|
|
bobainfotail Get info from the lasts 5 archives
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobainfoall Get info from all archives in the repository (can be long and cpu intensive)
|
2022-12-18 17:11:33 +01:00
|
|
|
|
bobagencachedirfile Create CACHEDIR.TAG file into the current folder
|
2021-10-24 15:46:39 +02:00
|
|
|
|
|
|
|
|
|
bobadel Delete the archive in argument
|
|
|
|
|
bobadelast Delete the last archive in the repository
|
|
|
|
|
bobacheckrepo Check the repo consistency without repairing it (to avoid data lost)
|
|
|
|
|
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobamount Mount archive in argument in the home dir of the current user
|
|
|
|
|
bobamountfirst Mount first archive in the home dir of the current user
|
|
|
|
|
bobamountlast Mount last archive in the home dir of the current user
|
2021-10-24 15:46:39 +02:00
|
|
|
|
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobasearchinrepo Search for a file in the repository, the function will display a list of all archives that contain the match
|
|
|
|
|
bobasearchinarchive Search for a file in the archive in argument, displaying full path in the archive
|
2021-10-24 15:46:39 +02:00
|
|
|
|
1st argument: archive, 2nd argument: text to find
|
|
|
|
|
bobadurationr Show name and backup duration for all archive in the current repo (can be long and cpu intensive)
|
|
|
|
|
bobadur List the name of all archives and sizes (O, C, D) (can be long and cpu intensive)
|
|
|
|
|
bobalstimes List all archives with dates and times creation
|
|
|
|
|
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobadeleter Mass archives deleting
|
2021-08-08 09:14:56 +02:00
|
|
|
|
bobagrepdeleter Mass archives deleting with filter as argument
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobarenamer Mass archives renaming
|
2023-04-25 14:17:27 +02:00
|
|
|
|
bobagreprenamer Mass archives renaming with filter as argument
|
2022-04-25 18:25:07 +02:00
|
|
|
|
bobaextractallfiles Extract all versions found of a file given in parameter
|
2021-10-24 15:46:39 +02:00
|
|
|
|
bobacachedel Delete the cache dir of a repository (do not delete any archive)
|
|
|
|
|
bobasecuritydel Delete the security folder from a repository (do not delete any archive)
|
|
|
|
|
bobapassphrase Enter passphrase that will be used all env var by all borg repo in the same terminal
|
2021-04-05 11:18:32 +02:00
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobaaide() {
|
2021-04-05 11:18:32 +02:00
|
|
|
|
cat << EOF
|
|
|
|
|
BorgBackup alias and functions (by Djan GICQUEL)
|
|
|
|
|
---
|
|
|
|
|
bobals Lister les archives du dépôt
|
2021-08-08 09:14:56 +02:00
|
|
|
|
bobagrepls Lister les archives du dépôt avec un filtre en argument
|
2021-10-24 15:46:39 +02:00
|
|
|
|
bobainfoa Obtenir les informations d’une archive en argument
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobainfor Obtenir les informations d’un dépôt
|
|
|
|
|
bobainfolast Obtenir les informations de la dernière archive
|
2023-09-18 13:14:02 +02:00
|
|
|
|
bobainfotail Obtenir les informations des 5 dernières archives
|
2021-10-24 15:46:39 +02:00
|
|
|
|
bobainfoall Affiche les infos de toutes les archives du dépôt (peut être long)
|
2022-12-18 17:11:33 +01:00
|
|
|
|
bobagencachedirfile Créer un fichier CACHEDIR.TAG dans le dossier courant
|
2021-10-24 15:46:39 +02:00
|
|
|
|
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobadel Supprimer l'archive en paramètre
|
|
|
|
|
bobadelast Supprimer la dernière archive du dépôt
|
|
|
|
|
bobacheckrepo Vérifier la consistance d'un dépôt sans le réparer (pour éviter les pertes de donnée)
|
2021-10-24 15:46:39 +02:00
|
|
|
|
|
|
|
|
|
bobamount Monter une archive en paramètre dans le home de l'utilisateur courant
|
|
|
|
|
bobamountfirst Monter la première archive dans le home de l'utilisateur courant
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobamountlast Monter la dernière archive dans le home de l'utilisateur courant
|
2021-10-24 15:46:39 +02:00
|
|
|
|
|
|
|
|
|
bobasearchinrepo Chercher un fichier (en argument) dans le dépôt, affiche le nom de toutes les archives qui contienne le fichier
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobasearchinarchive Chercher un fichier dans une archive en argument, affiche le chemin dans l'archive
|
2021-10-24 15:46:39 +02:00
|
|
|
|
bobadurationr Montrer le nom de toutes les archives et le temps de sauvegarde
|
|
|
|
|
bobadur Lister le nom de toutes les archives et leurs tailles (originale, compressée, dédupliquée)
|
|
|
|
|
bobalstimes Lister toutes les archives du dépôt avec les dates et heures de création
|
|
|
|
|
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobadeleter Supprimer facilement plusieurs archives d'un dépôt
|
2021-08-08 09:14:56 +02:00
|
|
|
|
bobagrepdeleter Supprimer facilement plusieurs archives d'un dépôt avec un filtre en argument
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobarenamer Renommer en masses les archives d'un dépôt
|
2023-04-25 14:17:27 +02:00
|
|
|
|
bobagreprenamer Renommer en masses les archives d'un dépôt avec un filtre en argument
|
2022-04-25 18:25:07 +02:00
|
|
|
|
bobaextractallfiles Extraire toutes les versions d'un fichier donné en argument
|
2021-04-05 11:18:32 +02:00
|
|
|
|
bobacachedel Supprimer le cache d'un dépôt (ne supprime aucune archive)
|
|
|
|
|
bobasecuritydel Supprimer le dossier security d'un dépôt (ne supprime aucune archive)
|
2021-10-24 15:46:39 +02:00
|
|
|
|
bobapassphrase Entrer une phrase de passe en tant que variable d'environnement qui sera utilisé par les dépôts pour le terminal courant
|
2021-04-05 11:18:32 +02:00
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alias bobahelp="bobaman"
|
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
###############################################################################
|
|
|
|
|
# generals functions
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
TestBorgRepo() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
if [ ! -f "config" ]; then
|
|
|
|
|
TestBorgErr=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -d "data" ]; then
|
|
|
|
|
TestBorgErr=1
|
2022-08-16 09:55:36 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$TestBorgErr" = "1" ];then
|
|
|
|
|
echo "Not in a borg repo."
|
|
|
|
|
echo "Exiting in 5 seconds."
|
|
|
|
|
sleep 5
|
|
|
|
|
return
|
2021-04-05 11:20:00 +02:00
|
|
|
|
fi
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
UnMount() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
fusermount -u -z "$mountpoint"
|
|
|
|
|
sleep 5
|
|
|
|
|
rmdir "$mountpoint"
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
DirExists() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
if [ ! -d "$1" ]; then
|
|
|
|
|
echo "Error, directory $1 missing."
|
|
|
|
|
echo "Exiting.";sleep 10
|
|
|
|
|
exit
|
|
|
|
|
fi
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobapassphrase() {
|
2021-10-12 16:42:22 +02:00
|
|
|
|
stty -echo
|
|
|
|
|
read -p "Enter borg passphrase : " BORG_PASSPHRASE
|
|
|
|
|
stty echo
|
|
|
|
|
echo ""
|
|
|
|
|
export BORG_PASSPHRASE
|
|
|
|
|
}
|
2021-04-05 11:11:02 +02:00
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobagencachedirfile() {
|
2022-12-18 17:11:33 +01:00
|
|
|
|
echo "Signature: 8a477f597d28d172789f06886806bc55" > CACHEDIR.TAG && echo "CACHEDIR.TAG created"
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
###############################################################################
|
|
|
|
|
# list and infos functions
|
|
|
|
|
###############################################################################
|
2021-04-05 11:11:02 +02:00
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobals() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
2021-04-05 11:11:02 +02:00
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
borg list --short ./
|
2021-09-28 13:53:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobalstimes() {
|
2021-09-28 13:53:20 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
borg list --format {barchive}{SPACE}{SPACE}{TAB}{start}{NL} ./
|
2021-04-05 11:20:00 +02:00
|
|
|
|
}
|
2021-04-05 11:11:02 +02:00
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobagrepls() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
2023-09-13 10:32:42 +02:00
|
|
|
|
borg list --short --glob-archives "$1" ./
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobainfoa() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
borg info ./::$1
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobainfor() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
borg info ./
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobainfolast() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
archive=$(borg list --short ./ | tail -n 1)
|
2022-07-30 17:04:56 +02:00
|
|
|
|
borg info .::"$archive"
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobainfotail() {
|
2021-09-28 13:53:20 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
for archive in $(borg list --short ./ | tail -n 5);do
|
|
|
|
|
echo "----------------------------------------------------"
|
|
|
|
|
borg info .::$archive
|
|
|
|
|
echo "----------------------------------------------------"
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobainfoall() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
for borgarchive in $(borg list --short ./);do
|
|
|
|
|
echo "------------------------------------------------------------------------------"
|
|
|
|
|
borg info .::$borgarchive
|
|
|
|
|
echo "------------------------------------------------------------------------------"
|
|
|
|
|
done
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobastats() {
|
2022-08-25 14:09:40 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
if ! which jq ;then
|
|
|
|
|
echo "Install jq and retry."
|
|
|
|
|
else
|
|
|
|
|
echo "name,duration,original_size,compressed_size,deduplicated_size" > borg-stats-$(date +%Y-%m-%d).csv
|
|
|
|
|
for borgarchive in $(borg list --short ./);do
|
2022-11-12 09:26:49 +01:00
|
|
|
|
echo "Processing "$borgarchive...""
|
2022-08-25 14:09:40 +02:00
|
|
|
|
borg info --json .::"$borgarchive" | jq -r '.archives[] | [.name,.duration,.stats.original_size,.stats.compressed_size,.stats.deduplicated_size] | @csv' >> "borg-stats-$(date +%Y-%m-%d).csv"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobadurationr() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
for borgarchive in $(borg list --short ./);do
|
|
|
|
|
borg info .::$borgarchive | grep "Archive name"
|
|
|
|
|
borg info .::$borgarchive | grep "Duration"
|
|
|
|
|
echo ""
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobadur() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
2025-01-25 13:48:13 +01:00
|
|
|
|
echo "Prefered units ?"
|
|
|
|
|
select choice in B KB MB GB;do
|
|
|
|
|
case $choice in
|
|
|
|
|
B)
|
|
|
|
|
echo "Processing all archives..."
|
|
|
|
|
borg info --json --glob-archives "*" ./ | jq -r '.archives[] | [.name,(.stats.original_size),(.stats.compressed_size),(.stats.deduplicated_size)] | @csv' >> ./bobadurtmp.csv
|
|
|
|
|
column --separator "," --table --table-columns "NAME,ORIG (B),COMP (B),DEDUP (B)" ./bobadurtmp.csv
|
|
|
|
|
echo ""
|
|
|
|
|
rm -i ./bobadurtmp.csv
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
KB)
|
|
|
|
|
echo "Processing all archives..."
|
|
|
|
|
borg info --json --glob-archives "*" ./ | jq -r '.archives[] | [.name,(.stats.original_size/1000|round/100),(.stats.compressed_size/1000|round/100),(.stats.deduplicated_size/1000|round/100)] | @csv' >> ./bobadurtmp.csv
|
|
|
|
|
column --separator "," --table --table-columns "NAME,ORIG (KB),COMP (KB),DEDUP (KB)" ./bobadurtmp.csv
|
|
|
|
|
echo ""
|
|
|
|
|
rm -i ./bobadurtmp.csv
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
MB)
|
|
|
|
|
echo "Processing all archives..."
|
|
|
|
|
borg info --json --glob-archives "*" ./ | jq -r '.archives[] | [.name,(.stats.original_size/1000/1000|round/100),(.stats.compressed_size/1000/1000|round/100),(.stats.deduplicated_size/1000/1000|round/100)] | @csv' >> ./bobadurtmp.csv
|
|
|
|
|
column --separator "," --table --table-columns "NAME,ORIG (MB),COMP (MB),DEDUP (MB)" ./bobadurtmp.csv
|
|
|
|
|
echo ""
|
|
|
|
|
rm -i ./bobadurtmp.csv
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
GB)
|
|
|
|
|
echo "Processing all archives..."
|
|
|
|
|
borg info --json --glob-archives "*" ./ | jq -r '.archives[] | [.name,(.stats.original_size/1000/1000/1000|round/100),(.stats.compressed_size/1000/1000/1000|round/100),(.stats.deduplicated_size/1000/1000/1000|round/100)] | @csv' >> ./bobadurtmp.csv
|
|
|
|
|
column --separator "," --table --table-columns "NAME,ORIG (GB),COMP (GB),DEDUP (GB)" ./bobadurtmp.csv
|
|
|
|
|
echo ""
|
|
|
|
|
rm -i ./bobadurtmp.csv
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2021-04-05 11:20:00 +02:00
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# mount functions
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobamount() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
mountpoint="$HOME/borg_$1"
|
|
|
|
|
mkdir $mountpoint
|
|
|
|
|
echo "Archive : $1"
|
2022-07-30 17:04:56 +02:00
|
|
|
|
borg mount ./::"$1" $mountpoint
|
2021-04-05 11:20:00 +02:00
|
|
|
|
read -p "Presser une touche pour démontage" CONT
|
|
|
|
|
UnMount
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobamountfirst() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
archive=$(borg list ./ --short | head -n 1)
|
|
|
|
|
mountpoint="$HOME/borg_$archive"
|
2022-07-30 17:04:56 +02:00
|
|
|
|
mkdir "$mountpoint"
|
|
|
|
|
borg mount ./::"$archive" "$mountpoint"
|
2021-04-05 11:20:00 +02:00
|
|
|
|
|
|
|
|
|
read -p "Presser une touche pour démontage" CONT
|
|
|
|
|
UnMount
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobamountlast() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
2022-07-30 17:04:56 +02:00
|
|
|
|
archive="$(borg list ./ --short | tail -n 1)"
|
2021-04-05 11:20:00 +02:00
|
|
|
|
mountpoint="$HOME/borg_$archive"
|
2022-07-30 17:04:56 +02:00
|
|
|
|
mkdir "$mountpoint"
|
|
|
|
|
borg mount ./::"$archive" "$mountpoint"
|
2021-04-05 11:20:00 +02:00
|
|
|
|
|
|
|
|
|
read -p "Presser une touche pour démontage" CONT
|
|
|
|
|
UnMount
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# search functions
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobasearchinrepo() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
for borgarchive in $(borg list --short ./);do
|
|
|
|
|
borggrep=$(borg list --short .::$borgarchive | grep -i $1)
|
|
|
|
|
if [ $? = 0 ];then
|
|
|
|
|
echo ""
|
|
|
|
|
echo "-- $borgarchive --"
|
|
|
|
|
echo "$borggrep"
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
|
|
|
|
done
|
2021-04-05 11:11:02 +02:00
|
|
|
|
}
|
2021-04-05 11:15:32 +02:00
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobasearchinarchive() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
2022-07-30 17:04:56 +02:00
|
|
|
|
borg list --short .::"$1" | grep -i "$2"
|
2021-04-05 11:20:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobacachedel() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
repoid=$(cat config | grep id | cut -f3 -d" ")
|
|
|
|
|
echo "Repo ID : "$repoid;sleep 5
|
|
|
|
|
DirExists $HOME/.cache/borg/$repoid
|
|
|
|
|
rm -r $HOME/.cache/borg/$repoid
|
2021-04-05 11:16:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobasecuritydel() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
repoid=$(cat config | grep id | cut -f3 -d" ")
|
|
|
|
|
echo "Repo ID : "$repoid;sleep 5
|
|
|
|
|
DirExists $HOME/.config/borg/security/$repoid
|
|
|
|
|
rm -r $HOME/.config/borg/security/$repoid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# modify repo
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobadel() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
borg delete ./::$1
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobadelast() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
archive=$(borg list ./ --short | tail -n 1)
|
|
|
|
|
borg delete .::$archive
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobacheckrepo() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
borgrepo="${PWD##*/}"
|
|
|
|
|
|
|
|
|
|
borg check -v .
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# mass functions
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobadeleter() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
2021-04-05 11:16:05 +02:00
|
|
|
|
borgrepo="${PWD##*/}"
|
|
|
|
|
file="borgdelete_$borgrepo.sh"
|
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
borg list --short . >> $file
|
|
|
|
|
if [ "$?" != "0" ]; then echo "Error generating list of archives. Exiting." && return;fi
|
2021-09-29 08:55:02 +02:00
|
|
|
|
|
|
|
|
|
sed -i 's/^/#/' $file #add "#" in the beginnning of all lines
|
2021-04-05 11:16:05 +02:00
|
|
|
|
|
2021-09-29 08:55:02 +02:00
|
|
|
|
echo ""
|
|
|
|
|
echo "In the next screen just uncomment lines you want to delete and save your file";sleep 3
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
$EDITOR $file
|
|
|
|
|
sed -i '/^#/d' $file #remove lines without "#"
|
2021-10-07 12:57:36 +02:00
|
|
|
|
sed -i 's/^/"/' $file # add quotes in the beginnning of lines
|
|
|
|
|
sed -i 's/$/"/' $file # add quotes ine the end of lines
|
2021-09-29 08:55:02 +02:00
|
|
|
|
paste -s -d " " $file > file_temp
|
|
|
|
|
rm $file;mv file_temp $file
|
|
|
|
|
|
2022-04-10 11:50:56 +02:00
|
|
|
|
sed -i '1s/^/borg delete -v --list .::/' $file
|
2021-04-05 11:16:05 +02:00
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
sed -i '1s/^/\n/' $file
|
|
|
|
|
sed -i '1s/^/\n/' $file
|
|
|
|
|
sed -i '1s/^/#Watch out you'\''re doing, there won'\''t be other confirmation\n/' $file
|
|
|
|
|
sed -i '1s/^/\n/' $file
|
|
|
|
|
sed -i '1s/^/### BORG DELETER ###\n/' $file
|
|
|
|
|
|
|
|
|
|
$EDITOR $file
|
|
|
|
|
sh $file
|
|
|
|
|
rm $file
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobagrepdeleter() {
|
2021-04-05 11:20:00 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
|
|
borgrepo="${PWD##*/}"
|
|
|
|
|
file="borgdelete_$borgrepo.sh"
|
2023-09-13 10:32:42 +02:00
|
|
|
|
borg list --short --glob-archives "$1" ./ >> $file
|
2021-04-05 11:20:00 +02:00
|
|
|
|
if [ "$?" != "0" ]; then echo "Error generating list of archives. Exiting." && rm $file && return;fi
|
2021-04-05 11:16:05 +02:00
|
|
|
|
|
|
|
|
|
sed -i 's/^/"/' $file
|
|
|
|
|
sed -i 's/$/"/' $file
|
2022-04-10 11:50:56 +02:00
|
|
|
|
sed -i 's/^/#borg delete -v --list .::/' $file
|
2021-04-05 11:16:05 +02:00
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
sed -i '1s/^/\n/' $file
|
|
|
|
|
sed -i '1s/^/\n/' $file
|
|
|
|
|
sed -i '1s/^/#Watch out you'\''re doing, there won'\''t be other confirmation.\n/' $file
|
|
|
|
|
sed -i '1s/^/#Just uncomment lines you want to delete and save your file.\n/' $file
|
|
|
|
|
sed -i '1s/^/\n/' $file
|
|
|
|
|
sed -i '1s/^/### BORG GREP DELETER ###\n/' $file
|
2021-04-05 11:16:05 +02:00
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
$EDITOR $file
|
2021-04-05 11:16:05 +02:00
|
|
|
|
sh $file
|
|
|
|
|
rm $file
|
2021-04-05 11:17:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 11:20:00 +02:00
|
|
|
|
|
2021-04-05 11:17:28 +02:00
|
|
|
|
# mass archive renaming
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobarenamer() {
|
2021-04-05 11:17:28 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
which paste || echo "Paste command not found." exit
|
|
|
|
|
|
|
|
|
|
borgrepo="${PWD##*/}"
|
|
|
|
|
file="file_$borgrepo.txt"
|
|
|
|
|
originals="originals_$borgrepo.txt"
|
|
|
|
|
script="borgrenamer_$borgrepo.sh"
|
|
|
|
|
|
|
|
|
|
echo "Generating list of archives..."
|
|
|
|
|
borg list --short . >> $originals
|
|
|
|
|
if [ "$?" != "0" ]; then echo "Error generating list of archives. Exiting." && return;fi
|
2023-04-25 14:17:27 +02:00
|
|
|
|
|
|
|
|
|
cp $originals $file
|
|
|
|
|
|
|
|
|
|
$EDITOR $file
|
|
|
|
|
sed -i 's/^/"/' $originals
|
|
|
|
|
sed -i 's/$/"/' $originals
|
|
|
|
|
sed -i 's/^/borg rename -v .::/' $originals
|
|
|
|
|
|
|
|
|
|
sed -i 's/^/"/' $file
|
|
|
|
|
sed -i 's/$/"/' $file
|
|
|
|
|
|
|
|
|
|
paste -d" " $originals $file > $script
|
|
|
|
|
|
|
|
|
|
sed -i '1s/^/\n/' $script
|
|
|
|
|
sed -i '1s/^/\n/' $script
|
|
|
|
|
sed -i '1s/^/\n/' $script
|
|
|
|
|
sed -i '1s/^/#Modifications in this file will be applied\, comment all to cancel\.\n/' $script
|
|
|
|
|
sed -i '1s/^/### BORG RENAMER ###\n/' $script
|
|
|
|
|
|
|
|
|
|
$EDITOR $script
|
|
|
|
|
|
|
|
|
|
echo "Renaming..."
|
|
|
|
|
sh $script
|
|
|
|
|
rm $file
|
|
|
|
|
rm $originals
|
|
|
|
|
rm $script
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobagreprenamer() {
|
2023-04-25 14:17:27 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
which paste || echo "Paste command not found." exit
|
|
|
|
|
|
|
|
|
|
borgrepo="${PWD##*/}"
|
|
|
|
|
file="file_$borgrepo.txt"
|
|
|
|
|
originals="originals_$borgrepo.txt"
|
|
|
|
|
script="borgrenamer_$borgrepo.sh"
|
|
|
|
|
|
|
|
|
|
echo "Generating list of archives..."
|
2023-09-13 10:32:42 +02:00
|
|
|
|
borg list --glob-archives "$1" --short . >> $originals
|
2023-04-25 14:17:27 +02:00
|
|
|
|
if [ "$?" != "0" ]; then echo "Error generating list of archives. Exiting." && return;fi
|
2021-04-05 11:17:28 +02:00
|
|
|
|
|
|
|
|
|
cp $originals $file
|
|
|
|
|
|
|
|
|
|
$EDITOR $file
|
|
|
|
|
sed -i 's/^/"/' $originals
|
|
|
|
|
sed -i 's/$/"/' $originals
|
|
|
|
|
sed -i 's/^/borg rename -v .::/' $originals
|
|
|
|
|
|
|
|
|
|
sed -i 's/^/"/' $file
|
|
|
|
|
sed -i 's/$/"/' $file
|
|
|
|
|
|
|
|
|
|
paste -d" " $originals $file > $script
|
|
|
|
|
|
|
|
|
|
sed -i '1s/^/\n/' $script
|
|
|
|
|
sed -i '1s/^/\n/' $script
|
|
|
|
|
sed -i '1s/^/\n/' $script
|
|
|
|
|
sed -i '1s/^/#Modifications in this file will be applied\, comment all to cancel\.\n/' $script
|
|
|
|
|
sed -i '1s/^/### BORG RENAMER ###\n/' $script
|
|
|
|
|
|
|
|
|
|
$EDITOR $script
|
|
|
|
|
|
|
|
|
|
echo "Renaming..."
|
|
|
|
|
sh $script
|
|
|
|
|
rm $file
|
|
|
|
|
rm $originals
|
|
|
|
|
rm $script
|
2021-04-05 11:20:00 +02:00
|
|
|
|
}
|
2022-04-25 18:25:07 +02:00
|
|
|
|
|
2024-08-23 10:52:06 +02:00
|
|
|
|
bobaextractallfiles() {
|
2022-04-25 18:25:07 +02:00
|
|
|
|
TestBorgRepo
|
|
|
|
|
export BORG_REPO=$(echo $PWD)
|
|
|
|
|
export BorgName=$(echo ${PWD##*/})
|
|
|
|
|
mkdir -p $HOME/BorgExtract_"$BorgName"/;cd $HOME/BorgExtract_"$BorgName"
|
|
|
|
|
|
|
|
|
|
for ar in $(borg list --short $BORG_REPO);do
|
2023-09-13 10:32:42 +02:00
|
|
|
|
path=$(borg list --glob-archives "$1" --format '{path}{NL}' ::$ar)
|
2022-04-25 18:25:07 +02:00
|
|
|
|
if [ $? = 0 ];then
|
|
|
|
|
mkdir -p $ar;cd $ar
|
|
|
|
|
borg extract --list ::$ar $path
|
|
|
|
|
cd ..
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
cd $BORG_REPO
|
|
|
|
|
}
|