Checking necessary available disk space before doing backup

Many thanks to @ScIT-Raphael and HestiaCP
https://github.com/hestiacp/hestiacp/pull/1141
This commit is contained in:
myvesta 2020-09-10 22:49:53 +02:00 committed by GitHub
commit fd47112fc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,6 +54,15 @@ start_time=$(date '+%s')
subj="$user → backup failed"
email=$(grep CONTACT $VESTA/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=" $VESTA/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
BACKUP_TEMP=$BACKUP
fi