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-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
|
|
|
|
|
|
|
|
# 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.")
|
|
|
|
zenity --width=500 --error --text="$infoerr"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "data" ]; then
|
|
|
|
TestBorgErr=1
|
|
|
|
infoerr=$(echo "Impossible de trouver le fichier de configuration borg.")
|
|
|
|
zenity --width=500 --error --text="$infoerr"
|
|
|
|
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")
|
|
|
|
zenity --width=500 --error --text="$infoerr"
|
|
|
|
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
|
|
|
|
inforerror=$(echo "Erreur, le dossier $1 est absent.\nFin du script.")
|
|
|
|
zenity --width=500 --error --text="$inforerror"
|
|
|
|
exit
|
|
|
|
fi
|
2021-03-07 14:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SauvegardeBorg () {
|
2021-03-07 15:42:18 +01:00
|
|
|
DossierPresent $borg_repo
|
|
|
|
DossierPresent $borg_dir
|
|
|
|
|
2021-03-09 20:14:03 +01:00
|
|
|
zenity --width=500 --height=600 --info --text="<tt>$(cd $dossierprofil && cat $fichierprofil)</tt>"
|
2021-03-07 15:42:18 +01:00
|
|
|
|
|
|
|
borg create $borg_excludes $borg_compress $borg_repo::$borg_archive $borg_dir | zenity --width=400 --progress --pulsate --auto-close --title="Sauvegarde en cours..."
|
|
|
|
sync | zenity --width=400 --progress --pulsate --auto-close --title="Synchronisation des écritures..."
|
|
|
|
zenity --notification --text "Sauvegarde $nomsauvegarde terminée"
|
|
|
|
zenity --width=300 --info --text "Sauvegarde $nomsauvegarde terminée"
|
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
|
|
|
|
fichierprofil=$(ls -1 $HOME/.config/borg/*.txt | zenity --height=500 --width=600 --list --title "Profils" --column "profil") && . $fichierprofil
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$nomsauvegarde" = "" ]; then
|
2021-03-07 15:42:18 +01:00
|
|
|
infoerr=$(echo "Nom de sauvegarde non défini.")
|
2021-03-07 14:52:30 +01:00
|
|
|
zenity --width=200 --error --text="$infoerr"
|
|
|
|
exit
|
|
|
|
elif [ "$borg_repo" = "" ]; then
|
2021-03-07 15:42:18 +01:00
|
|
|
infoerr=$(echo "Variable \$borg_repo absente")
|
2021-03-07 14:52:30 +01:00
|
|
|
zenity --width=200 --error --text="$infoerr"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $borg_repo
|
|
|
|
TestBorgRepo
|
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
# MENU PRINCIPAL
|
|
|
|
#################################################################################
|
|
|
|
|
|
|
|
#################################################################################
|
|
|
|
# Gestion des options du menu
|
|
|
|
#################################################################################
|
|
|
|
while [ ! "$choixmenu" = "QUITTER" ]
|
|
|
|
do
|
|
|
|
choixmenu=$(echo -e "\
|
|
|
|
creer_sauvegarde\n\
|
|
|
|
monter_sauvegarde\n\
|
|
|
|
demonter_sauvegarde\n\
|
|
|
|
supprimmer_sauvegarde\n\
|
|
|
|
info_sauvegarde\n\
|
|
|
|
info_depot\n\
|
2021-03-09 20:17:30 +01:00
|
|
|
afficher_profil\n\
|
2021-03-07 14:52:30 +01:00
|
|
|
QUITTER\
|
2021-03-07 15:42:18 +01:00
|
|
|
" | zenity --list --height=400 --width=400 --title "BORG GUI" --column "Nom : $nomsauvegarde")
|
2021-03-07 14:52:30 +01:00
|
|
|
|
|
|
|
if [ "$choixmenu" = "creer_sauvegarde" ] ;then
|
|
|
|
TestBorgRepo
|
|
|
|
SauvegardeBorg
|
|
|
|
|
|
|
|
elif [ "$choixmenu" = "monter_sauvegarde" ];then
|
|
|
|
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --list --title "Listes des archives" --column "Archive")
|
|
|
|
mkdir $HOME/$borg_archive
|
|
|
|
borg mount $borg_repo::$borg_archive $HOME/$borg_archive
|
|
|
|
zenity --width=400 --info --text="La sauvegarde est disponible dans le dossier\n$HOME/$borg_archive"
|
|
|
|
|
|
|
|
elif [ "$choixmenu" = "demonter_sauvegarde" ];then
|
|
|
|
ptnmontage=$(mount | grep borgfs | cut -d" " -f3 | zenity --width=500 --height=400 --list --title "Liste des points de montages" --column "")
|
|
|
|
fusermount -u $ptnmontage
|
|
|
|
sleep 5
|
|
|
|
rmdir $ptnmontage
|
|
|
|
|
|
|
|
elif [ "$choixmenu" = "supprimmer_sauvegarde" ];then
|
|
|
|
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --list --title "Listes des archives" --column "Archive")
|
2021-03-07 15:42:18 +01:00
|
|
|
borg delete $borg_repo::$borg_archive | zenity --width=400 --progress --pulsate --auto-close --title="Suppression en cours..."
|
2021-03-07 14:52:30 +01:00
|
|
|
zenity --width=200 --info --text="Suppresion terminée"
|
|
|
|
|
|
|
|
elif [ "$choixmenu" = "info_sauvegarde" ];then
|
|
|
|
borg_archive=$(borg list --short $borg_repo | zenity --height=500 --list --title "Listes des archives" --column "Archive")
|
|
|
|
info=$(borg info $borg_repo::$borg_archive)
|
|
|
|
zenity --width=600 --info --text="$info"
|
|
|
|
|
|
|
|
elif [ "$choixmenu" = "info_depot" ];then
|
|
|
|
info=$(borg info $borg_repo)
|
|
|
|
zenity --width=600 --info --text="$info"
|
|
|
|
|
2021-03-09 20:17:30 +01:00
|
|
|
elif [ "$choixmenu" = "afficher_profil" ];then
|
2021-03-07 14:52:30 +01:00
|
|
|
info=$(cd $dossierprofil && cat $fichierprofil)
|
2021-03-09 20:14:03 +01:00
|
|
|
zenity --width=600 --height=400 --info --text="<tt>$info</tt>"
|
2021-03-07 15:42:18 +01:00
|
|
|
|
|
|
|
elif [ "$choixmenu" = "" ];then
|
|
|
|
zenity --width=500 --info --text="Aucun choix, retour au menu."
|
2021-03-07 14:52:30 +01:00
|
|
|
fi
|
|
|
|
done
|