v-delete-user-backup-exclusions 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # info: delete backup exclusion
  3. # options: USER [SYSTEM]
  4. #
  5. # The function for deleting backup exclusion
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. system=$(echo $2 | tr '[:lower:]' '[:upper:]')
  12. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/conf/vesta.conf
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. check_args '1' "$#" 'USER [SYSTEM]'
  19. is_format_valid 'user'
  20. is_object_valid 'user' 'USER' "$user"
  21. #----------------------------------------------------------#
  22. # Action #
  23. #----------------------------------------------------------#
  24. # Delete system exclusion
  25. if [ -z "$system" ]; then
  26. WEB=''
  27. DNS=''
  28. MAIL=''
  29. DB=''
  30. CRON=''
  31. USER=''
  32. else
  33. touch $USER_DATA/backup-excludes.conf
  34. source $USER_DATA/backup-excludes.conf
  35. case $system in
  36. WEB) WEB='';;
  37. DNS) DNS='';;
  38. MAIL) MAIL='';;
  39. DB) DB='';;
  40. CRON) CRON='';;
  41. USER) USER='';;
  42. esac
  43. fi
  44. # Updating exlusion list
  45. echo "WEB='$WEB'" > $USER_DATA/backup-excludes.conf
  46. echo "DNS='$DNS'" >> $USER_DATA/backup-excludes.conf
  47. echo "MAIL='$MAIL'" >> $USER_DATA/backup-excludes.conf
  48. echo "DB='$DB'" >> $USER_DATA/backup-excludes.conf
  49. echo "CRON='$DB'" >> $USER_DATA/backup-excludes.conf
  50. echo "USER='$USER'" >> $USER_DATA/backup-excludes.conf
  51. chmod 660 $USER_DATA/backup-excludes.conf
  52. #----------------------------------------------------------#
  53. # Vesta #
  54. #----------------------------------------------------------#
  55. # Logging
  56. if [ -z "$system" ]; then
  57. log_history "deleted all exlusions"
  58. else
  59. log_history "deleted $system exlusion"
  60. fi
  61. log_event "$OK" "$ARGUMENTS"
  62. exit