我有一些代码可以从我们的开发服务器传输备份,它的随机行为似乎非常奇怪,并给出以下错误/输出:
Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-22-04-blahjob_dev18.tgz
PHP Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-22-37-blahjob_dev19.tgz
PHP Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-23-05-blahjob_dev5.tgz
PHP Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-23-37-blahjob_dev33.tgz
我一点也不知道 delete 与 有什么关系ftp_get()
,或者它为什么返回false
并发出有关另一个操作成功的警告。谷歌在发现任何类似问题方面也无济于事。
有问题的代码:
// ftp connection established, file list acquired, yadda yadda
foreach( $targets as $target ) {
$localfile = $backup_dir . $target;
if( file_exists($localfile) ) {
do_log($task['name'], "Local file ".$target." already exists, skipping.", 1);
continue;
}
if( ! ftp_get($conn, $localfile, $target, FTP_BINARY) ) { // line 106
do_log($task['name'], "Failed to get file: ".$target, 2);
} else {
do_log($task['name'], "Got file: ".$target);
ftp_delete($conn, $target);
}
}