diff --git a/borgaliasandfunctions.txt b/borgaliasandfunctions.txt index e581014..bec2171 100644 --- a/borgaliasandfunctions.txt +++ b/borgaliasandfunctions.txt @@ -79,4 +79,46 @@ borggrep=$(borg list --short .::$borgarchive | grep $1) echo "Chaine trouvé dans l'archive : $borgarchive" fi done +} + +#Supprimmer en masse des archives dans un dépôt +function bobadeleter { + borgrepo="${PWD##*/}" + file="borgdelete_$borgrepo.sh" + editor="$EDITOR" + + #test dépôt + borgrepofile="config" + if [ ! -f "$borgrepofile" ]; then + echo "Not in a borg repo. Unable to find $borgrepofile." + return + fi + + borgrepofile="data" + if [ ! -d "$borgrepofile" ]; then + echo "Not in a borg repo. Unable to find $borgrepofile." + return + fi + + #générer la liste des archives + borg list --short . >> $file + if [ "$?" != "0" ]; then + echo "Error." + return + fi + + sed -i 's/^/"/' $file + sed -i 's/$/"/' $file + sed -i 's/^/#borg delete -v .::/' $file + + clear + echo "### BORG DELETER ###" + echo "" + echo "Just uncomment lines you want to delete and save your file." + echo "Watch out you're doing, there won't be other confirmation." + sleep 5 + + $editor $file + sh $file + rm $file } \ No newline at end of file