v-backup-users 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # info: backup all users
  3. # options: NONE
  4. # labels:
  5. #
  6. # example: v-backup-users
  7. #
  8. # The function backups all system users.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Importing system environment as we run this script
  13. # mostly by cron which not read it by itself
  14. source /etc/profile
  15. # Includes
  16. source $HESTIA/func/main.sh
  17. source $HESTIA/conf/hestia.conf
  18. #----------------------------------------------------------#
  19. # Action #
  20. #----------------------------------------------------------#
  21. # Auto-repair all databases before backuping all accounts
  22. mysqlrepair --all-databases --check --auto-repair > /dev/null 2>&1
  23. if [ -z "$BACKUP_SYSTEM" ]; then
  24. exit
  25. fi
  26. for user in $($HESTIA/bin/v-list-sys-users plain); do
  27. check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
  28. log=$HESTIA/log/backup.log
  29. if [ ! -f "$HESTIA/data/users/$user/user.conf" ]; then
  30. continue;
  31. fi
  32. check_backup_conditions
  33. check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
  34. log=$HESTIA/log/backup.log
  35. if [ ! -z "$check_suspend" ]; then
  36. echo -e "================================" >> $log
  37. echo -e "$user" >> $log
  38. echo -e "--------------------------------\n" >> $log
  39. nice -n 19 ionice -c2 -n7 $BIN/v-backup-user $user >> $log 2>&1
  40. echo -e "\n--------------------------------\n\n" >> $log
  41. fi
  42. done
  43. #----------------------------------------------------------#
  44. # Hestia #
  45. #----------------------------------------------------------#
  46. # No Logging
  47. #log_event "$OK" "$ARGUMENTS"
  48. exit