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';

  'mysqldump --opt -h%s -u%s -p%s %s | gzip > %s/backup/' . time() . '.sql.gz',

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.

Accepted Answer

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.

Written by Matt Gibson
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki