Hi, I am trying to create a small script that will backup a MySQL database. I can successfully create the backup file at the root of my Website using:
Back up MySQL file?
3
Hi,
I am trying to create a small script that will backup a MySQL database. I can successfully create the backup file at the root of my Website using:
However, I would like the script to save the file to a FTP server elsewhere. I have added the variables for the FTP server, like so:
But what do I need to add to mysqldump for the file to be sent to the FTP server?
I've been searching for hours and can't find a solution that works. Any help will be much appreciated.
Many thanks,
T
I am trying to create a small script that will backup a MySQL database. I can successfully create the backup file at the root of my Website using:
Code:
<?php
// This PHP Script will backup the content of a MySQL database in a GZip file
// Enter Database access details
$host= 'HOSTNAME';
$user= 'USERNAME';
$pass= 'PASSWRD';
$db= 'DBNAME';
// Instructing the system to zip and store the database
system(sprintf(
'mysqldump --opt -h%s -u%s -p%s %s | gzip > $s/dumpDB.sql.gz',
$host,
$user,
$pass,
$db,
getenv('DOCUMENT_ROOT')
));
echo '+DONE';
?> Code:
<?php
// This PHP Script will backup the content of a MySQL database in a GZip file
// Enter Database access details
$host= 'HOSTNAME';
$user= 'USERNAME';
$pass= 'PASSWRD';
$db= 'DBNAME';
// FTP Server access details
$ftphost= 'FTPHOSTHAME';
$ftpdir= 'FTPDIR';
$ftpuser= 'FTPUSERNAME';
$ftppass= 'FTPPASSWRD';
// Instructing the system to zip and store the database
system(sprintf(
'mysqldump --opt -h%s -u%s -p%s %s | gzip > $s/dumpDB.sql.gz',
$host,
$user,
$pass,
$db,
getenv('DOCUMENT_ROOT')
));
echo '+DONE';
?> I've been searching for hours and can't find a solution that works. Any help will be much appreciated.
Many thanks,
T
- mywebwork
- [ 1 ] Thanks
- Amsterdam
Next Topics on Trending Feed
-
3