This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TODO : | |
# fonction f_rsync#{{{ | |
function f_rsync | |
{ | |
# Test si la destination existe et que c'est un répertoire | |
if [[ -e $2 ]] && [[ -d $2 ]]; then | |
backup="/Volumes/MyShare/backup/"; | |
clear | |
echo "----------------------------------------------------" | |
echo "-------- $2 ---------" | |
echo "----------------------------------------------------" | |
# Sauvegarde en mirroir des documents | |
rsync --archive --verbose --backup --itemize-changes --out-format="%i %n%L" \ | |
--stats --human-readable --partial --progress --exclude=".DS_Store" \ | |
--delete-after --backup-dir=$backup $1 $2 | |
echo -e "\n" | |
else | |
echo -e "\nla destination $2 est inaccessible !" | |
fi | |
} | |
#}}} | |
# Démarrage#{{{ | |
while [[ -z $choix ]]; do | |
clear | |
echo "----------------------------------------------------" | |
echo "------------------- ./rsync.sh ---------------------" | |
echo -e "----------------------------------------------------\n" | |
echo -e "Faites un choix parmis ses dossiers :\n" | |
echo "(1) Synchroniser Documents" | |
echo "(2) Synchroniser Pictures" | |
echo "(3) Synchroniser Music" | |
echo -e "(Q) Quitter\n" | |
read -p "Votre choix ? : " -n 1 choix | |
case $choix in | |
1) doc_src="/Users/fl4t/Documents/"; | |
doc_dest="/Volumes/MyShare/rsync/Documents/";; | |
2) doc_src="/Users/fl4t/Pictures/"; | |
doc_dest="/Volumes/MyShare/rsync/Pictures/";; | |
3) doc_src="/Users/fl4t/Music/"; | |
doc_dest="/Volumes/MyShare/rsync/Music/";; | |
Q|q) echo -e "\n\nA plus !"; | |
exit;; | |
esac | |
if [[ $choix = 1 ]] || [[ $choix = 2 ]] || [[ $choix = 3 ]]; then | |
f_rsync $doc_src $doc_dest; | |
else | |
echo -e "\nle choix $choix n'existe pas"; | |
sleep 2; | |
choix=""; | |
fi | |
done | |
#}}} |
Bisoux.