开发者

mysqldump: got errno 32 on write (1and1 shared host) as crontab

开发者 https://www.devze.com 2023-02-19 05:12 出处:网络
I\'m using the exact code that 1and1 suggests for backing up MySQL DBs through mysqldump (http://faq.1and1.co.uk/archive/43.html)

I'm using the exact code that 1and1 suggests for backing up MySQL DBs through mysqldump (http://faq.1and1.co.uk/archive/43.html)

$host= 'xxxx';
$user= 'xxxx';
$pass= 'xxxx';
$db=   'xxxx';

system(sprintf(
  'mysqldump --op开发者_如何学Got -h%s -u%s -p%s %s | gzip > %s/backup/' . time() . '.sql.gz',
  $host,
  $user,
  $pass,
  $db,
  getenv('DOCUMENT_ROOT')
));

Have changed all permissions to 777 for purposes of testing. Still no luck. Continuing to get the error (errno 32 on write).

Any help is appreciated - this seems like a stupid fix.


If you're doing this from a cron job, then DOCUMENT_ROOT won't exist. The DOCUMENT_ROOT and other $_SERVER variables are effectively set up by the web server (see the $_SERVER manual page), and if you're running the script directly from cron, there's no web server involved. See this earlier, similar question.

Try setting the path to your backup directory relative to the location of the PHP script. For example, if your script is in .../your_folder/scripts/backup_script.php, and your (pre-created) backup directory is .../your_folder/backup/, then

$backup_dir = dirname(__FILE__) . '/../backup';

...and then use $backup_dir instead of getenv('DOCUMENT_ROOT').

It looks like your hosts's instructions are correct, but only if running the script from the web server, not from the command line.

0

精彩评论

暂无评论...
验证码 换一张
取 消