This is probably a PERL JOB, but if you want to propose it as PHP, please do and explain.
HERE'S HOW THE SCRIPT SHOULD WORK
1. When script starts, get the current hour (1-24), day of week (MO, TU, WE, TH, FR, SA, SU), and day of month (1-31). For each record of the backup table (see below), if the current hour == hours field AND the current day of week OR day of month is within the days field, process that record (otherwise skip to next record). If processing:
1.1 ) Get source directory or file.
- Exclude sub-directories whose name matches any item in exclude_dirs.
- Exclude files within the source directory and it's sub-directories whose name matches any item in exclude_dirs.
- Exclude files within the source directory and it's sub-directories whose file extension matches any item in exclude_types.
1.2) Create a zip archive with yymmddhhmmss appended.
1.3) Put zip file in dest_local directory.
1.4) Put zip file in dest_remote server/directory using ssh (or specify another secure method).
1.5) Record backup date in last_day field, backup time in last_time field, outcome in last_outcome field (ok, remote error, etc.).
1.6) Append outcome to outcomes var (or temp file).
2) Once all records are done, if outcome var is not empty, send it in an emal.
source - full path
dest_local - full path
dest_remote - IP or FQDN of server, user, password, path
exclude_dirs - csv
exclude_files - csv
exclude_types - csv
hours - eg: 2,14 means at 2:00 and 14:00
days - MO, TU, WE, TH, FR, SA, SU, 1-31 - eg: MO, 2, 12 means Monday, the 2nd day of the month, and the 12th day of the month
last_day - date of last attempted processing
last_time - time of last attempted processing
last_outcome - outcome of last attempted processing
Minimum number of script files possible (config within script).
Speed is NOT important. Logical, easy to follow structure IS important. Comment extensively. Declare configuration variables early in script (emal address, SQL user, SQL pwd) and comment config in detail.
Linux server. Can add whatever Perl modules are needed. If PHP used, version 5. MySQL 4.