v-schedule-user-restore 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # info: schedule user backup restoration
  3. # options: USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR]
  4. #
  5. # The function for scheduling user backup restoration.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. backup=$2
  12. web=$3
  13. dns=$4
  14. mail=$5
  15. db=$6
  16. cron=$7
  17. udir=$8
  18. # Includes
  19. source $VESTA/func/main.sh
  20. source $VESTA/conf/vesta.conf
  21. # Check backup ownership function
  22. is_backup_available() {
  23. passed=false
  24. if [[ $2 =~ ^$1.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]_[0-9][0-9]-[0-9][0-9]-[0-9][0-9].tar$ ]]; then
  25. passed=true
  26. elif [[ $2 =~ ^$1.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].tar$ ]]; then
  27. passed=true
  28. fi
  29. if [ $passed = false ]; then
  30. check_result $E_FORBIDEN "permission denied"
  31. fi
  32. }
  33. #----------------------------------------------------------#
  34. # Verifications #
  35. #----------------------------------------------------------#
  36. check_args '2' "$#" 'USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR]'
  37. is_format_valid 'user'
  38. is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM'
  39. is_object_valid 'user' 'USER' "$user"
  40. is_backup_enabled
  41. is_backup_scheduled 'restore'
  42. is_backup_available "$user" "$backup"
  43. #----------------------------------------------------------#
  44. # Action #
  45. #----------------------------------------------------------#
  46. # Adding restore task to the queue
  47. log=$VESTA/log/restore.log
  48. options="'$web' '$dns' '$mail' '$db' '$cron' '$udir'"
  49. echo "$BIN/v-restore-user $user $backup $options yes >> $log 2>&1" >>\
  50. $VESTA/data/queue/backup.pipe
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. # Logging
  55. log_event "$OK" "$ARGUMENTS"
  56. exit