I have a backup system..... that backs up a folder every 5 minutes. The backup can be assigned to any device using its IP Address. But once a week or once a month that device is rebooted, and we want to turn the backup off every week or month on a certain time for certain seconds. Creating the database table shouldn't be a problem, I was wondering if there is any way we can do this in a function
The Tables are structured as below
Device
Id BIGINT(20), //Auto Increment Id of the Device
Name VARCHAR(255), //Name of the device
Backup TINYINT(1) //Boolean to represent weather the device is backed or not
TurnOffBackup
Id BIGINT(20), //Id of the Table
deviceId BIGINT(20), //DeviceId Foriegn Key
weekDay TINYINT(1), //The week day to turn it off
monthDate INT(2), //The month date to turn it off
fortime BIGINT(20) //The number of seconds to turn the device off for
At the moment my select for devices to be backedup are as follows
SELECT * FROM Device WHERE backup=1
What i wana achieve is
SELECT * FROM Device WHERE backup=1 AND TURNBACKUPOFF(Device.Id)=0
Any idea how i would do this or should i be considiring doing this in code rather than in a MySQL Function