#!/bin/sh
# Directadmin user_backup_pre.sh check free disk space script
# put in /usr/local/directadmin/scripts/custom/user_backup_pre.sh
# chmod to 755

# PARTITION set to /home's partition. If no /home partition, set to / (root) partition
PARTITION=/dev/sda6
# MAXUSED disk space percents allowed
MAXUSED=90

checkfree()
{
         DISKUSED=`df -P $PARTITION | awk '{print $5}' | grep % | cut -d% -f1`
          echo "$DISKUSED < $MAXUSED" | bc
}
          if [ `checkfree` -eq 0 ]; then
                    echo "$PARTITION disk usage is above $MAXUSED% Aborting backup.";
                    exit 1;
          fi
exit 0;
