miamondo

backup_rsync.sh

Feb 5th, 2022 (edited)
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.07 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Copyright © 2022 Benoît Boudaud <https://miamondo.org/contact>
  4. # This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
  5. # License as published by the Free Software Foundation, either version 3 of the License, or any later version.
  6. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
  7. # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  8. # You should have received a copy of the GNU General Public License along with this program.
  9. # If not, see <http://www.gnu.org/licenses/>
  10.  
  11. # Auteur : Benoît Boudaud
  12. # Nom du script : backup_rsync.sh
  13. # Fonction : Synchronisation et sauvegarde du répertoire utilisateur
  14.  
  15. # ---- TRADUCTIONS -----------------------------------------------------------------------------------------------------
  16.  
  17. nl_title="SYNCHRONISATIE EN BACK-UP VAN DE GEBRUIKERSMAP"
  18. fr_title="SYNCHRONISATION ET SAUVEGARDE DU RÉPERTOIRE UTILISATEUR"
  19.  
  20. nl_to="Standaardbestemming: $USER@server-boudaud\n\
  21. Druk op de Enter toets als u hier tevreden mee bent, of voer een andere bestemming in."
  22. fr_to="Destination par défaut: $USER@server-boudaud\n\
  23. Pressez la touche Entrée si cela vous convient, ou renseignez une autre destination."
  24.  
  25. nl_default_sync="Standaard gesynchroniseerde mappen: Documenten Afbeeldingen Muziek 'Video\'s'\n\
  26. Druk op de Enter toets als u hier tevreden mee bent, of Voer andere de te synchroniseren mappen in, gescheiden door een spatie."
  27. fr_default_sync="Répertoires synchronisés par défaut: Documents Images Musique Videos\n\
  28. Pressez la touche Entrée si cela vous convient, ou choisissez d'autres répertoires à synchroniser, en les séparant par un espace."
  29.  
  30. nl_end="Gedaan. Druk op de Enter-toets."
  31. fr_end="Terminé. Veuillez presser la touche Entrée."
  32.  
  33.  
  34. if [[ "$LANG" == "nl_NL.UTF-8" ]]; then  # Nederlands
  35.     title=$nl_title
  36.     to=$nl_to
  37.     default_sync=$nl_default_sync
  38.     default_directories=(Documenten Afbeeldingen Muziek "Video's")
  39.     end=$nl_end
  40. elif [[ "$LANG" == "fr_FR.UTF-8" ]]; then  # Français
  41.     title=$fr_title
  42.     to=$fr_to
  43.     default_sync=$fr_default_sync
  44.     default_directories=(Documents Images Musique Videos)
  45.     end=$fr_end
  46. fi
  47.  
  48. echo $title
  49. echo
  50. echo -e $to
  51.  
  52. # --- CHOIX DE LA DESTINATION ------------------------------------------------------------------------------------------
  53.  
  54. default_destination="$USER@server-boudaud"
  55. read destination
  56. destination=${destination:-${default_destination}}
  57. echo $destination
  58. echo
  59.  
  60. # ---- CHOIX DES RÉPERTOIRES À SYNCHRONISER ----------------------------------------------------------------------------
  61.  
  62. echo -e $default_sync
  63. read directories
  64. directories=${directories:-${default_directories[@]}}
  65. echo $directories
  66.  
  67. # ---- SYNCHRONISATION ET MISE À JOUR DU SUPPORT DE SAUVEGARDE ---------------------------------------------------------
  68.  
  69. rsync -avz --delete-after ${directories[@]} $destination:/home/$(echo $destination | cut -d '@' -f 1)
  70. echo
  71. echo $end
  72. read
  73.  
Add Comment
Please, Sign In to add comment