v-backup-users 1.7 KB

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