Browse Source

Merge pull request #1141 from hestiacp/fix/1115_backup-space-check

Add a free disk space validation during backup routine.
Jaap Marcus 5 years ago
parent
commit
9cd0fa5154
2 changed files with 11 additions and 0 deletions
  1. 2 0
      CHANGELOG.md
  2. 9 0
      bin/v-backup-user

+ 2 - 0
CHANGELOG.md

@@ -30,6 +30,8 @@ All notable changes to this project will be documented in this file.
 - Fixed an issue with Restore Failed on Domains with Mail Setups using SSL (#1069)
 - Fixed an issue with Restore Failed on Domains with Mail Setups using SSL (#1069)
 - Fixed an issue with PHPMyAdmin button (#1078)
 - Fixed an issue with PHPMyAdmin button (#1078)
 - Changed WordPress name in Webapp installer (#1074)
 - Changed WordPress name in Webapp installer (#1074)
+- Add a free disk space validation during backup routine (#1115)
+
 
 
 ## [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