backup 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #! /bin/bash
  2. function backup {
  3. if mount | grep "on $2 type" > /dev/null
  4. then
  5. sudo rsync -av --delete-before /home $3
  6. sudo rsync -av --delete-before /etc $3
  7. sudo rsync -av --delete-before /var $3
  8. sudo rsync -av --delete-before \
  9. --exclude=Téléchargements \
  10. --exclude=Steam \
  11. --exclude=.atom \
  12. --exclude=Dropbox \
  13. --exclude=Musique/banshee-playlists \
  14. /mnt/Data $3
  15. else
  16. echo "$1 is not mounted"
  17. fi
  18. }
  19. if [ "$1" = "qnap" ]; then
  20. if mount | grep "on /mnt/Qnap/bachir type" > /dev/null
  21. then
  22. sudo rsync -av --delete-before /home /mnt/Qnap/bachir/bach_backups
  23. sudo rsync -av --delete-before /etc /mnt/Qnap/bachir/bach_backups
  24. sudo rsync -av --delete-before /var /mnt/Qnap/bachir/bach_backups
  25. sudo rsync -av --delete-before \
  26. --exclude=Téléchargements \
  27. --exclude=Steam \
  28. --exclude=.atom \
  29. --exclude=Dropbox \
  30. --exclude=Musique/banshee-playlists \
  31. /mnt/Data /mnt/Qnap/bachir/bach_backups
  32. else
  33. echo "Qnap/bachir is not mounted"
  34. fi
  35. elif [ "$1" = "extdata" ]; then
  36. if mount | grep "on /mnt/ExtData type" > /dev/null
  37. then
  38. sudo rsync -av --delete-before /home /mnt/ExtData/
  39. sudo rsync -av --delete-before /etc /mnt/ExtData/
  40. sudo rsync -av --delete-before /var /mnt/ExtData/
  41. sudo rsync -av --delete-before \
  42. --exclude=Téléchargements \
  43. --exclude=Steam \
  44. --exclude=.atom \
  45. --exclude=Dropbox \
  46. --exclude=Musique/banshee-playlists \
  47. /mnt/Data /mnt/ExtData/
  48. else
  49. echo "ExtData is not mounted"
  50. fi
  51. elif [ "$1" = "raidbox" ]; then
  52. backup "RaidBox" "/mnt/RaidBox" "/mnt/RaidBox/backup/"
  53. #if mount | grep "on /mnt/RaidBox type" > /dev/null
  54. #then
  55. # sudo rsync -av --delete-before /home /mnt/RaidBox/
  56. # sudo rsync -av --delete-before /etc /mnt/RaidBox/
  57. # sudo rsync -av --delete-before /var /mnt/RaidBox/
  58. # sudo rsync -av --delete-before \
  59. # --exclude=Téléchargements \
  60. # --exclude=Steam \
  61. # --exclude=.atom \
  62. # --exclude=Dropbox \
  63. # --exclude=Musique/banshee-playlists \
  64. # /mnt/Data /mnt/RaidBox/
  65. #else
  66. # echo "RaidBox is not mounted"
  67. #fi
  68. else
  69. echo "please choose a backup destination : qnap or extdata or raidbox"
  70. echo "don't forget to mount the destination before launching this script"
  71. fi