Limiting Reseller and User Level Backup to only be able to run at specific times

If your don't want to increase the load of your system at peak hours and wish to only allow backups to be created by Resellers/Users within a certain range of time, you can use the all_pre.sh script to do so.

In this example we will code the all_pre.sh for the CMD_USER_BACKUP and the CMD_SITE_BACKUP to only be able to create backups between the hours of 1am and 8am.

Create /usr/local/directadmin/scripts/custom/all_pre.sh, and fill it with this code:

#!/bin/sh

MAKINGBACKUP=0
if [ "$command" = "/CMD_USER_BACKUP" ]; then
    if [ "$action" = "create" ]; then
        MAKINGBACKUP=1
    fi
fi

if [ "$command" = "/CMD_SITE_BACKUP" ]; then
    if [ "$action" = "backup" ]; then
        MAKINGBACKUP=1
    fi
fi
if [ "$MAKINGBACKUP" -eq 1 ]; then
    HOUR=`date +%k`
    if [ "$HOUR" -ge 1 ] && [ "$HOUR" -lt 8 ]; then
        //this is a valid time, exit.
        exit 0;
    else
        echo "Backups must be created between 1am and 8am";
        exit 1;
    fi
fi
exit 0;

chmod the all_pre.sh to 755.

 
config/limiting.txt · Last modified: 2010/02/22 08:07 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Please visit Automatic Backlinks to start earning free backlinks Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki