{"id":3544,"date":"2021-12-08T09:59:06","date_gmt":"2021-12-08T09:59:06","guid":{"rendered":"https:\/\/ownwebservers.com\/kb\/?p=3544"},"modified":"2021-12-08T12:55:57","modified_gmt":"2021-12-08T12:55:57","slug":"setting-email-alert-when-backup-limit-exceeds","status":"publish","type":"post","link":"https:\/\/ownwebservers.com\/kb\/setting-email-alert-when-backup-limit-exceeds\/","title":{"rendered":"Setting email alert when backup limit exceeds"},"content":{"rendered":"<p>If you have hosted your web site on a VPS or a dedicated server, you would possibly like to get an update if this current backup disk-space limit exceeds.<\/p>\n<p>So here is a step by step method to create a disk-space monitoring script that may send you an email if the backup limit exceeds.<\/p>\n<p>To your server, you must be already having root access.<\/p>\n<p><strong>Step: 1.<\/strong>\u00a0Login to your server with SSH<\/p>\n<p><strong>Step: 2.<\/strong>\u00a0Run the following commands to create a\u00a0script:<\/p>\n<blockquote><p>touch \/etc\/cron.daily\/backupDiskCheck.cron<br \/>\nchmod 755 \/etc\/cron.daily\/backupDiskCheck.cron<\/p><\/blockquote>\n<p><strong>Step: 3.<\/strong>\u00a0Now by using a text editor like nano create the following script:<\/p>\n<blockquote>\n<div id=\"crayon-618259f835962065079110\" class=\"crayon-syntax crayon-theme-1c-kod crayon-font-monaco crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">nano \/etc\/cron.daily\/backupDiskCheck.cron<\/div>\n<\/blockquote>\n<div data-settings=\" minimize scroll-mouseover\"><\/div>\n<div data-settings=\" minimize scroll-mouseover\">\n<p>Change the\u00a0<em>user@example.com<\/em>\u00a0address and the\u00a0<em>10<\/em>\u00a0threshold below:<\/p>\n<blockquote>\n<div id=\"crayon-618259f835966601230010\" class=\"crayon-syntax crayon-theme-1c-kod crayon-font-monaco crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\">#!\/bin\/bash<br \/>\nADMIN=&#8221;user@example.com&#8221;<br \/>\nTHRESHOLD=10<br \/>\ndf -h | awk &#8216;\/\\\/$\/ {print $3,$NF}&#8217; | while read output;<br \/>\ndo<br \/>\nusedDisk=$(echo $output | awk &#8216;{print $1}&#8217; | sed &#8216;s#G##&#8217;)<br \/>\npartition=$(echo $output | awk &#8216;{print $2}&#8217;)<br \/>\nif [ $usedDisk -ge $THRESHOLD ] &amp;&amp; [ $partition = &#8220;\/&#8221; ]<br \/>\nthen<br \/>\necho &#8220;$(date +%d\/\\%h\/%Y&#8221; &#8220;%T): Your server $(hostname) is OVER the \\<br \/>\n$(echo $THRESHOLD)G automatic backup limit, you&#8217;re using $(echo $usedDisk)G on \\<br \/>\nthe $partition partition.&#8221; | mail -s&#8221;Alert: Over Automatic Backup limit&#8221; $ADMIN<br \/>\nfi<br \/>\ndone<\/div>\n<\/blockquote>\n<div data-settings=\" minimize scroll-mouseover\">\n<p><strong>Step: 4.<\/strong>\u00a0If 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.<\/p>\n<p>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.<\/p>\n<p>If the limit exceeds, you will receive an email at the email address you entered in the script.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you have hosted your web site on a VPS or a dedicated server, you would possibly like to get an update if this current backup disk-space limit exceeds. So here is a step by step method to create a disk-space monitoring script that may send you an email if the backup limit exceeds. To [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-3544","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/3544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/comments?post=3544"}],"version-history":[{"count":1,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/3544\/revisions"}],"predecessor-version":[{"id":3545,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/3544\/revisions\/3545"}],"wp:attachment":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/media?parent=3544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/categories?post=3544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/tags?post=3544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}