Skip to content

Commit 4982d92

Browse files
committed
Modify backup condition/load check and remove time limit.
1 parent 5b65230 commit 4982d92

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

bin/v-backup-user

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ is_backup_enabled
3939
# Action #
4040
#----------------------------------------------------------#
4141

42-
wait_for_backup_if_it_is_not_time_for_backup
42+
check_backup_conditions
4343

4444
# Set backup directory if undefined
4545
if [ -z "$BACKUP" ]; then
@@ -122,7 +122,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
122122
i=0
123123

124124
for domain in $web_list; do
125-
wait_for_backup_if_it_is_not_time_for_backup
125+
check_backup_conditions
126126
((i ++))
127127
echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
128128
mkdir -p $tmpdir/web/$domain/conf
@@ -296,7 +296,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
296296

297297
i=0
298298
for domain in $mail_list; do
299-
wait_for_backup_if_it_is_not_time_for_backup
299+
check_backup_conditions
300300
((i ++))
301301
echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
302302
mkdir -p $tmpdir/mail/$domain/conf
@@ -369,7 +369,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
369369
conf="$USER_DATA/db.conf"
370370
db_list=$(echo "$db_list" |sed -e "s/ */\ /g" -e "s/^ //")
371371
for database in $db_list; do
372-
wait_for_backup_if_it_is_not_time_for_backup
372+
check_backup_conditions
373373
((i ++))
374374
get_database_values
375375

@@ -476,7 +476,7 @@ if [ "$USER" != '*' ]; then
476476
udir_list="$udir_list $udir"
477477
echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
478478

479-
wait_for_backup_if_it_is_not_time_for_backup
479+
check_backup_conditions
480480

481481
# Backup files and dirs
482482
tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz

bin/v-backup-users

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
3434
if [ ! -f "$HESTIA/data/users/$user/user.conf" ]; then
3535
continue;
3636
fi
37-
wait_for_backup_if_it_is_not_time_for_backup
37+
check_backup_conditions
3838
check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
3939
log=$HESTIA/log/backup.log
4040
if [ ! -z "$check_suspend" ]; then

func/main.sh

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -940,38 +940,13 @@ format_aliases() {
940940
}
941941

942942

943-
wait_for_backup_if_it_is_not_time_for_backup() {
943+
check_backup_conditions() {
944944
# Checking load average
945945
la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
946946
# i=0
947947
while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
948948
echo -e "$(date "+%F %T") Load Average $la"
949949
sleep 60
950-
# if [ "$i" -ge "15" ]; then
951-
# la_error="LoadAverage $la is above threshold"
952-
# echo "$la_error" |$SENDMAIL -s "$subj" $email $notify
953-
# sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
954-
# check_result $E_LA "$la_error"
955-
# fi
956950
la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
957-
# (( ++i))
958951
done
959-
960-
# block backup if current hour is after 6 AM
961-
WAIT_LOOP_ENTERED=0
962-
if pgrep -x "v-backup-users" > /dev/null
963-
then
964-
hour=$(date +"%H");
965-
while [ "$hour" -gt "6" ]; do
966-
# if [ "$WAIT_LOOP_ENTERED" -eq 0 ]; then
967-
# do something when enter sleeping state
968-
# $BIN/v-restart-web-backend
969-
# fi
970-
WAIT_LOOP_ENTERED=1
971-
current_date_time="`date "+%Y-%m-%d %H:%M:%S"`";
972-
echo "$current_date_time - wait to backup user $user - current hour is $hour";
973-
sleep 300
974-
hour=$(date +"%H");
975-
done
976-
fi
977952
}

0 commit comments

Comments
 (0)