If you're on a VPS or dedicated server and paying for our automatic backup service, you might like to know when you've gone over the current backup disk-space limit you're paying for.

Email alert script

Below we'll create a disk-space monitoring script that can email us when our backup limit is exceeded.

This requires having root access to your server already.

  1. Login to your server with SSH
  2. Run the following commands to create our script:
    touch /etc/cron.daily/backupDiskCheck.cron
    chmod 755 /etc/cron.daily/backupDiskCheck.cron
    
  3. Now using a text editor like nano create the following script:
    nano /etc/cron.daily/backupDiskCheck.cron

     

    Change the user@example.com address and the 10 threshold below:

    #!/bin/bash
    ADMIN="user@example.com"
    THRESHOLD=10
    
    df -h | awk '/\/$/ {print $3,$NF}' | while read output;
    
    do
      usedDisk=$(echo $output | awk '{print $1}' | sed 's#G##')
      partition=$(echo $output | awk '{print $2}')
    
      if [ $usedDisk -ge $THRESHOLD ] && [ $partition = "/" ]
        then
        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
      fi
    done
  4. If you were following along and using nano to edit this file, you can now hit Ctrl-O to bring up the write file dialog, and then hit Enter to save your changes.

Now once a day your server should check to see if the disk-space usage is over the current level of automatic backups you're paying for.

If it does exceed this limit, then you should receive an email at the address you entered with a message like:

03/Sep/2013 16:28:04: Your server vps0123.inmotionhosting.com is currently OVER the 10G automatic backup limit, and is using 28G on the / partition.
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Write New!
Do you want to publish a tutorial to our support center?

News / Announcements

SSL Certficate Warnings
Updated 2014-04-14 11:34 am EST
Hits: 2219
Heartbleed 0-day OpenSSL security bug
Updated 2014-04-14 04:43 pm EST
Hits: 5641

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!