![]() | | ||||||||
| | #1 |
| Advanced Warrior Join Date: Jun 2005 Location: Wirral, UK
Posts: 691
Thanks: 2
Thanked 4 Times in 3 Posts
|
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: 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 |
| Web Design Wirral - Web Design, Hosting & Development from TDL Web Developments
| |
| | |
| | #2 |
| Senior Warrior Member War Room Member Join Date: Sep 2008 Location: Honolulu, Hawaii, USA & Montreal Canada
Posts: 2,218
Blog Entries: 1 Thanks: 759
Thanked 724 Times in 505 Posts
|
Could you just do the dump to the local directory as you're currently doing and then run another PHP function to FTP it to the remote server? Not sure if its useful to you but there is a good post here about using PHP to send files via FTP. PHP's FTP functions*tutorial Hope that helps. Bill |
| | |
| | #3 |
| Advanced Warrior Join Date: Jun 2005 Location: Wirral, UK
Posts: 691
Thanks: 2
Thanked 4 Times in 3 Posts
|
Yes, I think that will be the way to go. Thanks for the link ![]() T |
| Web Design Wirral - Web Design, Hosting & Development from TDL Web Developments
| |
| | |
![]() |
|
| Tags |
| back, file, mysql |
| Thread Tools | |
| |
![]() |