Преглед изворни кода

Modify backup condition/load check and remove time limit.

Raphael Schneeberger пре 7 година
родитељ
комит
4982d9235a
3 измењених фајлова са 7 додато и 32 уклоњено
  1. 5 5
      bin/v-backup-user
  2. 1 1
      bin/v-backup-users
  3. 1 26
      func/main.sh

+ 5 - 5
bin/v-backup-user

@@ -39,7 +39,7 @@ is_backup_enabled
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-wait_for_backup_if_it_is_not_time_for_backup
+check_backup_conditions
 
 
 # Set backup directory if undefined
 # Set backup directory if undefined
 if [ -z "$BACKUP" ]; then
 if [ -z "$BACKUP" ]; then
@@ -122,7 +122,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
     i=0
     i=0
 
 
     for domain in $web_list; do
     for domain in $web_list; do
-        wait_for_backup_if_it_is_not_time_for_backup
+        check_backup_conditions
         ((i ++))
         ((i ++))
         echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
         echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
         mkdir -p $tmpdir/web/$domain/conf
         mkdir -p $tmpdir/web/$domain/conf
@@ -296,7 +296,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
 
 
     i=0
     i=0
     for domain in $mail_list; do
     for domain in $mail_list; do
-        wait_for_backup_if_it_is_not_time_for_backup
+        check_backup_conditions
         ((i ++))
         ((i ++))
         echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
         echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
         mkdir -p $tmpdir/mail/$domain/conf
         mkdir -p $tmpdir/mail/$domain/conf
@@ -369,7 +369,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
     conf="$USER_DATA/db.conf"
     conf="$USER_DATA/db.conf"
     db_list=$(echo "$db_list" |sed -e "s/  */\ /g" -e "s/^ //")
     db_list=$(echo "$db_list" |sed -e "s/  */\ /g" -e "s/^ //")
     for database in $db_list; do
     for database in $db_list; do
-        wait_for_backup_if_it_is_not_time_for_backup
+        check_backup_conditions
         ((i ++))
         ((i ++))
         get_database_values
         get_database_values
 
 
@@ -476,7 +476,7 @@ if [ "$USER" != '*' ]; then
             udir_list="$udir_list $udir"
             udir_list="$udir_list $udir"
             echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
             echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
 
 
-            wait_for_backup_if_it_is_not_time_for_backup
+            check_backup_conditions
 
 
             # Backup files and dirs
             # Backup files and dirs
             tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
             tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz

+ 1 - 1
bin/v-backup-users

@@ -34,7 +34,7 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
     if [ ! -f "$HESTIA/data/users/$user/user.conf" ]; then
     if [ ! -f "$HESTIA/data/users/$user/user.conf" ]; then
         continue;
         continue;
     fi
     fi
-    wait_for_backup_if_it_is_not_time_for_backup
+    check_backup_conditions
     check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
     check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
     log=$HESTIA/log/backup.log
     log=$HESTIA/log/backup.log
     if [ ! -z "$check_suspend" ]; then
     if [ ! -z "$check_suspend" ]; then

+ 1 - 26
func/main.sh

@@ -940,38 +940,13 @@ format_aliases() {
 }
 }
 
 
 
 
-wait_for_backup_if_it_is_not_time_for_backup() {
+check_backup_conditions() {
     # Checking load average
     # Checking load average
     la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
     la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
     # i=0
     # i=0
     while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
     while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
         echo -e "$(date "+%F %T") Load Average $la"
         echo -e "$(date "+%F %T") Load Average $la"
         sleep 60
         sleep 60
-        # if [ "$i" -ge "15" ]; then
-            # la_error="LoadAverage $la is above threshold"
-            # echo "$la_error" |$SENDMAIL -s "$subj" $email $notify
-            # sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
-            # check_result $E_LA "$la_error"
-        # fi
         la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
         la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
-        # (( ++i))
     done
     done
-
-    # block backup if current hour is after 6 AM
-    WAIT_LOOP_ENTERED=0
-    if pgrep -x "v-backup-users" > /dev/null
-    then
-        hour=$(date +"%H");
-        while [ "$hour" -gt "6" ]; do
-            # if [ "$WAIT_LOOP_ENTERED" -eq 0 ]; then
-                # do something when enter sleeping state
-                # $BIN/v-restart-web-backend
-            # fi
-            WAIT_LOOP_ENTERED=1
-            current_date_time="`date "+%Y-%m-%d %H:%M:%S"`";
-            echo "$current_date_time - wait to backup user $user - current hour is $hour";
-            sleep 300
-            hour=$(date +"%H");
-        done
-    fi
 }
 }