| 189 | | require_once dirname(__FILE__)."/functions.inc.php"; |
|---|
| 190 | | backup_retrieve_backup_cron(); |
|---|
| 191 | | |
|---|
| | 189 | backup_install_retrieve_backup_cron(); |
|---|
| | 190 | |
|---|
| | 191 | function backup_install_retrieve_backup_cron(){ |
|---|
| | 192 | global $amp_conf,$db; |
|---|
| | 193 | |
|---|
| | 194 | $sql = "SELECT command, id from backup WHERE method NOT LIKE 'now%'"; |
|---|
| | 195 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 196 | |
|---|
| | 197 | if(empty($results)){ |
|---|
| | 198 | // grab any other cronjobs that are running as asterisk and NOT associated with backups |
|---|
| | 199 | // and issue the schedule to the cron scheduler |
|---|
| | 200 | exec("/usr/bin/crontab -l|grep -v '^# DO NOT'|grep -v ^'# ('|grep -v ampbackup.pl|grep -v ampbackup.php",$cron_out,$ret1); |
|---|
| | 201 | $cron_out_string = implode("\n",$cron_out); |
|---|
| | 202 | exec("/bin/echo '$cron_out_string' | /usr/bin/crontab -",$out_arr,$ret2); |
|---|
| | 203 | return ($ret1 == 0 && $ret2 == 0); |
|---|
| | 204 | } |
|---|
| | 205 | |
|---|
| | 206 | $backup_string = ""; |
|---|
| | 207 | foreach($results as $result){$backup_string.=$result['command'].' '.$result['id']."\n";} |
|---|
| | 208 | |
|---|
| | 209 | // grab any other cronjobs that are running as asterisk and NOT associated with backups, |
|---|
| | 210 | // combine with above and re-issue the schedule to the cron scheduler |
|---|
| | 211 | exec("/usr/bin/crontab -l|grep -v '^# DO NOT'|grep -v ^'# ('|grep -v ampbackup.pl|grep -v ampbackup.php",$cron_out,$ret1); |
|---|
| | 212 | $cron_out_string = implode("\n",$cron_out); |
|---|
| | 213 | $backup_string .= $cron_out_string; |
|---|
| | 214 | |
|---|
| | 215 | exec("/bin/echo '$backup_string' | /usr/bin/crontab -",$out_arr,$ret2); |
|---|
| | 216 | |
|---|
| | 217 | return ($ret1 == 0 && $ret2 == 0); |
|---|
| | 218 | } |
|---|