กำหนดขอบเขตเวลาสำหรับ backup

Create /usr/local/directadmin/scripts/custom/all_pre.sh

#!/bin/sh

HOUR=`date +%k`
MAKINGBACKUP=0
if [ “$command” = “/CMD_USER_BACKUP” ]; then
          if [ “$action” = “create” ]; then
                    //when=now or when=cron
                    MAKINGBACKUP=1
                    if [ “$when” = “cron” ]; then
                              HOUR=$hour
                    fi
          fi
fi

if [ “$command” = “/CMD_SITE_BACKUP” ]; then
          if [ “$action” = “backup” ]; then
                    MAKINGBACKUP=1
          fi
fi

if [ “$MAKINGBACKUP” -eq 1 ]; then
          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.

Was this article helpful?

Related Articles