i have to transfer a created sql file from server a to server b. Currently i tried following without success:
// Some SQL executions to fill and update the tables
( .. )
// Filename pattern
$fileName = "dump_".date("Y-m-d-H_i_s").".sql";
// Dump the tables and saves the output in dump directory
$dump = "mysqldump -u$USER -p$PASS $DB ".$this->dumpTables." > " . $this->path."dumps/". $fileName;
// Transfer the lastest sql file to the origin
$command = "scp " . $this->path."dbbackup/" . $fileName . " user@xxx.xxx.xxx.xxx:/PATH/dumps" . $fileName;
system($command, $retvalOrigin);
if ($retvalOrigin != 0) {
fwrite($this->logFileInstance, $this->date() . "Something went wrong!
");
fwrite($this->logFileInstance, $this->date() . "$command!
");
}
Whats the problem?
If i execute the command by hand, everything goes fine. So there is no permission problem. No unexpected log entries in my error log. If i copy the command without any vars and put this into a new php file, and call this, there is no error again.. At first i thougt scp hates me, thats why i replaced the "scp" with "rsync -ave". That gives me no error, but won't copy the file to the origin server (No error log again!).
scp -> $retvalOrigin = 1, no file on origin server, no error log
rsync -> $retvalOrigin = 0, no file on origin server, no error log
So what's the point?
Edit:
Path are ABSOLUTE, SSH KEY for the executing user and www-data - no login required anymore, $retVal includes ONLY 1 / 0, and NO in won't use for that a cron