在Ubuntu和并行plesk中使用cron作业备份数据库

时间:2014-10-16 13:58:39

标签: php cron

我使用php脚本备份我的数据库。以下是给定的脚本:

$datestamp = date("Y-m-d_h-i-s");     // Current date to append to filename of backup file in format of YYYY-MM-DD

/* CONFIGURE THE FOLLOWING FOUR VARIABLES TO MATCH YOUR SETUP */
$dbuser = "xyz";     // Database username
$dbpwd = "*****";     // Database password
$dbname = "mydatabase";     // Database name. Use --all-databases if you have more than one
$filename = "backup-$datestamp.sql.gz";     // The name (and optionally path) of the dump file

$command = "mysqldump -u $dbuser --password=$dbpwd $dbname | gzip > $filename";
$result = system($command);

以下是命令行

php5  /var/www/vhosts/cc.astra1641.startdedicated.de/httpdocs/cron/backup.php

我使用var_dump输出$ result变量来检查它是否返回空字符串。我也试过使用其他方法,如exec($ command)或passthru($ command),它不起作用。

0 个答案:

没有答案