我知道我做错的是不包括正确的完整文件路径信息,但是经过数小时的调整后,我仍然遇到sh: 2012-06-08-01-25.sql.gz: Permission denied mysqldump: Got errno 32 on write
错误。这是我的脚本:
$dbhost = "DATABASE HOST";
$dbuser = "DATABSE USER";
$dbpass = 'PASSWORD';
$dbname = "DATABASE NAME";
$backupfile = '/home/12345/data/backup/'.date("Y-m-dTH:i") . '.sql.gz';
system("mysqldump -h $dbhost -u $dbuser --password='$dbpass' $dbname | gzip > $backupfile");
$backupfile = $backupfile;
# To S3
require('/home/12345/data/backup/S3.php');
if (!defined('awsAccessKey')) define('awsAccessKey', 'ACCESS KEY');
if (!defined('awsSecretKey')) define('awsSecretKey', 'SECRET KEY');
$s3 = new S3(awsAccessKey, awsSecretKey);
if (!$s3->putObjectFile($backupfile, "BUCKET", 'db-backup/'.$backupfile, S3::ACL_PRIVATE)) {
die("104");
}
system("rm $backupfile");
该脚本使用 gzip 和 mysqldump 压缩我的数据库,然后将此 ZIP 上传到 S3 存储桶上的安全加密文件夹。