2021-03-07 14:52:30 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2021-03-07 15:42:18 +01:00
|
|
|
which zenity
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Zenity n'est pas installé.";exit
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-05-08 14:35:22 +02:00
|
|
|
which borg
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "borgbackup n'est pas installé.";exit
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-03-07 14:52:30 +01:00
|
|
|
# META VARIABLES
|
|
|
|
#################################################################################
|
|
|
|
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
|
|
|
|
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
2021-03-10 18:54:06 +01:00
|
|
|
dossierprofil="$HOME/.config/borg/"
|
2021-03-07 14:52:30 +01:00
|
|
|
|
|
|
|
# FONCTIONS
|
|
|
|
#################################################################################
|
|
|
|
TestBorgRepo () {
|
2021-03-07 15:42:18 +01:00
|
|
|
if [ ! -f "config" ]; then
|
|
|
|
TestBorgErr=1
|
|
|
|
infoerr=$(echo "Impossible de trouver le fichier de configuration borg.")
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --error --text="$infoerr"
|
2021-03-07 15:42:18 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "data" ]; then
|
|
|
|
TestBorgErr=1
|
|
|
|
infoerr=$(echo "Impossible de trouver le fichier de configuration borg.")
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --error --text="$infoerr"
|
2021-03-07 15:42:18 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "lock.exclusive" ]; then
|
|
|
|
TestBorgErr=1
|
|
|
|
infoerr=$(echo "Le dépôt est bloqué, une opération est peut-être en cours")
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --error --text="$infoerr"
|
2021-03-07 15:42:18 +01:00
|
|
|
exit
|
|
|
|
fi
|
2021-03-07 14:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bobainfoa () {
|
2021-03-07 15:42:18 +01:00
|
|
|
TestBorgRepo
|
|
|
|
borg info ./::$borg_repo
|
2021-03-07 14:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DossierPresent () {
|
2021-03-07 15:42:18 +01:00
|
|
|
if [ ! -d "$1" ]; then
|
2021-07-18 20:33:01 +02:00
|
|
|
inforerror=$(echo "Erreur, le dossier $1 est absent.")
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --error --text="$inforerror"
|
2021-07-18 20:33:01 +02:00
|
|
|
VarDossierPresent="false"
|
2021-03-07 15:42:18 +01:00
|
|
|
fi
|
2021-03-07 14:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Profils et tests
|
|
|
|
#################################################################################
|
|
|
|
# si $1 n'est pas vide fichier de profil = $1
|
|
|
|
# sinon afficher les profils disponibles
|
|
|
|
if [ ! $1 = "" ]; then
|
|
|
|
fichierprofil="$1"
|
|
|
|
. "$1"
|
|
|
|
else
|
2021-03-10 19:56:52 +01:00
|
|
|
cd $dossierprofil
|
2021-07-23 20:43:24 +02:00
|
|
|
fichierprofil=$(ls -1 *.txt | zenity --height=500 --width=600 --window-icon=$HOME/.icons/borg.svg --list --title "Liste des profils" --hide-header --column "profil") && . $fichierprofil
|
2021-03-07 14:52:30 +01:00
|
|
|
fi
|
|
|
|
|
2021-05-08 14:35:22 +02:00
|
|
|
if [ "$fichierprofil" = "" ]; then
|
|
|
|
infoerr=$(echo "Aucun profil choisi.")
|
|
|
|
zenity --width=600 --error --text="$infoerr"
|
|
|
|
exit
|
|
|
|
elif [ "$nomsauvegarde" = "" ]; then
|
2021-03-07 15:42:18 +01:00
|
|
|
infoerr=$(echo "Nom de sauvegarde non défini.")
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --error --text="$infoerr"
|
2021-03-07 14:52:30 +01:00
|
|
|
exit
|
|
|
|
elif [ "$borg_repo" = "" ]; then
|
2021-03-07 15:42:18 +01:00
|
|
|
infoerr=$(echo "Variable \$borg_repo absente")
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --error --text="$infoerr"
|
2021-03-07 14:52:30 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $borg_repo
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
# MENU PRINCIPAL
|
|
|
|
#################################################################################
|
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
# Gestion des options du menu
|
|
|
|
#################################################################################
|
2021-03-10 19:47:29 +01:00
|
|
|
while [ ! "$choixmenu" = "qu" ]
|
2021-03-07 14:52:30 +01:00
|
|
|
do
|
|
|
|
choixmenu=$(echo -e "\
|
2021-03-10 19:47:29 +01:00
|
|
|
cs\nCréer une archive\n\
|
|
|
|
ms\nMonter une archive\n\
|
|
|
|
dm\nDemonter une archive\n\
|
|
|
|
ss\nSupprimmer une archive\n\
|
|
|
|
is\nInformation archive\n\
|
2021-07-04 20:00:29 +02:00
|
|
|
fi\nFiltre : "$filter"\n\
|
|
|
|
--\n------------------------------------------\n\
|
2021-03-10 19:47:29 +01:00
|
|
|
id\nInformation sur le dépôt\n\
|
|
|
|
ap\nAfficher le profil\n\
|
2021-07-04 21:56:35 +02:00
|
|
|
--\n------------------------------------------\n\
|
|
|
|
ed\nEspace disque utilisé : $(df -k --output=pcent $borg_repo | tail -n +2)\n\
|
2021-03-10 19:47:29 +01:00
|
|
|
qu\nQuitter\
|
2021-07-23 20:43:24 +02:00
|
|
|
" | zenity --window-icon=$HOME/.icons/borg.svg --list \
|
2021-03-10 19:47:29 +01:00
|
|
|
--height=400 --width=400 \
|
|
|
|
--title "BORG GUI : $nomsauvegarde" \
|
|
|
|
--hide-header --hide-column=1 --column "id" --column "choix")
|
|
|
|
|
|
|
|
if [ "$choixmenu" = "cs" ] ;then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Créer une archive
|
|
|
|
|
2021-03-07 14:52:30 +01:00
|
|
|
TestBorgRepo
|
2021-03-19 20:10:42 +01:00
|
|
|
|
|
|
|
DossierPresent $borg_repo
|
|
|
|
DossierPresent $borg_dir
|
|
|
|
|
2021-07-18 20:33:01 +02:00
|
|
|
if [ "$VarDossierPresent" != "false" ];then
|
2021-07-23 20:43:24 +02:00
|
|
|
borg create $borg_excludes $borg_compress $borg_repo::$borg_archive $borg_dir | zenity --width=600 --window-icon=$HOME/.icons/borg.svg --progress --pulsate --auto-close --title="Sauvegarde en cours..."
|
|
|
|
sync | zenity --width=600 --window-icon=$HOME/.icons/borg.svg --progress --pulsate --auto-close --title="Synchronisation des écritures..."
|
2021-03-19 20:10:42 +01:00
|
|
|
zenity --notification --text "Sauvegarde $nomsauvegarde terminée"
|
|
|
|
zenity --width=600 --info --text "Sauvegarde $nomsauvegarde terminée"
|
2021-07-18 20:33:01 +02:00
|
|
|
fi
|
2021-03-07 14:52:30 +01:00
|
|
|
|
2021-03-10 19:47:29 +01:00
|
|
|
elif [ "$choixmenu" = "ms" ];then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Monter une archive
|
|
|
|
|
2021-07-04 21:54:04 +02:00
|
|
|
if [ "$filter" = "" ];then
|
2021-07-23 20:43:24 +02:00
|
|
|
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive")
|
2021-07-04 21:54:04 +02:00
|
|
|
else
|
2021-07-23 20:43:24 +02:00
|
|
|
borg_archive=$(borg list --short $borg_repo | grep $filter | zenity --height=500 --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive")
|
2021-07-04 21:54:04 +02:00
|
|
|
fi
|
|
|
|
|
2021-03-07 14:52:30 +01:00
|
|
|
mkdir $HOME/$borg_archive
|
2021-05-08 14:35:22 +02:00
|
|
|
borg mount $borg_repo::$borg_archive $HOME/$borg_archive | zenity --width=600 --progress --pulsate --auto-close
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --info --text="La sauvegarde est disponible dans le dossier\n<tt>$HOME/$borg_archive</tt>"
|
2021-03-07 14:52:30 +01:00
|
|
|
|
2021-03-10 19:47:29 +01:00
|
|
|
elif [ "$choixmenu" = "dm" ];then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Demonter une archive
|
|
|
|
|
2021-07-23 20:43:24 +02:00
|
|
|
ptnmontage=$(mount | grep borgfs | cut -d" " -f3 | zenity --width=500 --height=400 --window-icon=$HOME/.icons/borg.svg --list --title "Liste des points de montages" --column "Archive")
|
2021-05-08 14:35:22 +02:00
|
|
|
fusermount -u $ptnmontage | zenity --width=600 --progress --pulsate --auto-close
|
|
|
|
sleep 5 | zenity --width=600 --progress --pulsate --auto-close
|
|
|
|
rmdir $ptnmontage | zenity --width=600 --progress --pulsate --auto-close
|
2021-03-07 14:52:30 +01:00
|
|
|
|
2021-03-10 19:47:29 +01:00
|
|
|
elif [ "$choixmenu" = "ss" ];then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Supprimmer une archive
|
|
|
|
|
2021-07-04 21:54:04 +02:00
|
|
|
if [ "$filter" = "" ];then
|
2021-07-23 20:43:24 +02:00
|
|
|
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive")
|
2021-07-04 21:54:04 +02:00
|
|
|
else
|
2021-07-23 20:43:24 +02:00
|
|
|
borg_archive=$(borg list --short $borg_repo | grep $filter | zenity --height=500 --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive")
|
2021-07-04 21:54:04 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-06-27 19:50:09 +02:00
|
|
|
if [ "$borg_archive" = "" ];then
|
|
|
|
zenity --width=600 --info --text "Aucune archive choisie, retour au menu"
|
|
|
|
else
|
|
|
|
borg delete $borg_repo::$borg_archive | zenity --width=600 --progress --pulsate --auto-close
|
|
|
|
zenity --width=600 --info --text="Suppresion de l'archive $borg_archive terminée"
|
|
|
|
fi
|
|
|
|
|
2021-03-07 14:52:30 +01:00
|
|
|
|
2021-03-10 19:47:29 +01:00
|
|
|
elif [ "$choixmenu" = "is" ];then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Information archive
|
|
|
|
|
2021-07-04 21:54:04 +02:00
|
|
|
if [ "$filter" = "" ];then
|
2021-07-23 20:43:24 +02:00
|
|
|
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive")
|
2021-07-04 21:54:04 +02:00
|
|
|
else
|
2021-07-23 20:43:24 +02:00
|
|
|
borg_archive=$(borg list --short $borg_repo | grep $filter | zenity --height=500 --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive")
|
2021-07-04 21:54:04 +02:00
|
|
|
fi
|
|
|
|
|
2021-06-27 19:50:09 +02:00
|
|
|
if [ "$borg_archive" = "" ];then
|
|
|
|
zenity --width=600 --info --text "Aucune archive choisie, retour au menu"
|
|
|
|
else
|
|
|
|
zenity --width=600 --info --text="<tt>$(borg info $borg_repo::$borg_archive)</tt>" | zenity --width=600 --progress --pulsate --auto-close
|
|
|
|
fi
|
|
|
|
|
2021-07-04 20:00:29 +02:00
|
|
|
elif [ "$choixmenu" = "fi" ];then
|
|
|
|
#Filtre
|
|
|
|
|
|
|
|
filter=$(zenity --entry)
|
2021-03-07 14:52:30 +01:00
|
|
|
|
2021-03-10 19:47:29 +01:00
|
|
|
elif [ "$choixmenu" = "id" ];then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Information sur le dépôt
|
|
|
|
|
|
|
|
zenity --width=600 --info --text="<tt>$(borg info $borg_repo)</tt>" | zenity --width=600 --progress --pulsate --auto-close --title="Récupération des informations..."
|
2021-03-07 14:52:30 +01:00
|
|
|
|
2021-03-10 19:47:29 +01:00
|
|
|
elif [ "$choixmenu" = "ap" ];then
|
2021-05-08 14:35:22 +02:00
|
|
|
# Afficher le profil
|
|
|
|
|
2021-03-10 19:56:52 +01:00
|
|
|
zenity --width=600 --height=400 --info --text="<tt>$(cd $dossierprofil && cat $fichierprofil)</tt>"
|
2021-03-07 15:42:18 +01:00
|
|
|
|
|
|
|
elif [ "$choixmenu" = "" ];then
|
2021-03-10 20:07:52 +01:00
|
|
|
zenity --width=600 --info --text="Aucun choix, retour au menu."
|
2021-03-07 14:52:30 +01:00
|
|
|
fi
|
|
|
|
done
|