Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  How-Tos  >  Setting email alert when backup limit exceeds
Top Scroll

Setting email alert when backup limit exceeds

 2 min

If you have hosted your website on a VPS or a dedicated server, you might like to get an update if the current backup disk-space limit exceeds.

Email alert script

So here is a step by step process to create a disk-space monitoring script that can send you an email if the backup limit exceeds.

You must be already having root access to your server.

Step: 1. Login to your server with SSH

Step: 2. Run the following commands to create a script:

touch /etc/cron.daily/backupDiskCheck.cron
chmod 755 /etc/cron.daily/backupDiskCheck.cron

Step: 3. Now by using a text editor like nano create the following script:

nano /etc/cron.daily/backupDiskCheck.cron

Change the address and the 10 threshold below:

df -h | awk '/\/$/ {print $3,$NF}' | while read output;
  usedDisk=$(echo $output | awk '{print $1}' | sed 's#G##')
  partition=$(echo $output | awk '{print $2}')
  if [ $usedDisk -ge $THRESHOLD ] && [ $partition = "/" ]
    echo "$(date +%d/\%h/%Y" "%T): Your server $(hostname) is OVER the \
    $(echo $THRESHOLD)G automatic backup limit, you're using $(echo $usedDisk)G on \
    the $partition partition." | mail -s"Alert: Over Automatic Backup limit" $ADMIN

Step: 4. If you were following along and using nano to edit this file, you can now press Ctrl-O to bring up the write file dialog, and then press Enter to save the changes.

Now once a day your server will check to see if the disk-space usage is over the current level of automatic backups or not.

If the limit exceeds, you will receive an email at the email address you entered in the script.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.