Browse Source

Add a free disk space validation during backup routine.
This commit fixes #1115

Raphael Schneeberger 5 năm trước cách đây
mục cha
commit
35c2b2c72b
2 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 1 0
      CHANGELOG.md
  2. 9 0
      bin/v-backup-user

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
 - Upgrade process will now save logs to the `hst_backups` directory.
 - Upgrade process will now save logs to the `hst_backups` directory.
 
 
 ## Bugfixes
 ## Bugfixes
+- Add a free disk space validation during backup routine.
 
 
 ## [1.2.3] - Service Release
 ## [1.2.3] - Service Release
 ### Features
 ### Features

+ 9 - 0
bin/v-backup-user

@@ -55,6 +55,15 @@ start_time=$(date '+%s')
 subj="$user → backup failed"
 subj="$user → backup failed"
 email=$(grep CONTACT $HESTIA/data/users/admin/user.conf |cut -f 2 -d \')
 email=$(grep CONTACT $HESTIA/data/users/admin/user.conf |cut -f 2 -d \')
 
 
+# Validate available disk space (take usage * 2, due to the backup handling)
+let u_disk=$(grep "U_DISK=" $HESTIA/data/users/$user/user.conf |cut -f 2 -d \')*2
+let v_disk=$(($(stat -f --format="%a*%S" $BACKUP)))/1024/1024
+
+if [ "$u_disk" -gt "$v_disk" ]; then
+    echo "not enough diskspace available to perform the backup." |$SENDMAIL -s "$subj" $email $notify
+    check_result $E_LIMIT "not enough diskspace available to perform the backup."
+fi
+
 if [ -z "$BACKUP_TEMP" ]; then
 if [ -z "$BACKUP_TEMP" ]; then
     BACKUP_TEMP=$BACKUP
     BACKUP_TEMP=$BACKUP
 fi
 fi