hellonoko Posted November 30, 2007 Share Posted November 30, 2007 I have been looking for a tutorial for a script to backup my DB but haven't been able to find anything that seems to work. Can someone point me to a good tutorial or give me a simple example. Thanks for your time, ian Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/ Share on other sites More sharing options...
marcus Posted November 30, 2007 Share Posted November 30, 2007 http://www.php-mysql-tutorial.com/perform-mysql-backup-php.php excellent tutorial for what you should look into. Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/#findComment-402555 Share on other sites More sharing options...
hellonoko Posted November 30, 2007 Author Share Posted November 30, 2007 I looked at that one but it has 3 include files that it does not show. So unless I already knew what I was doing its no good. Played with it a bit but couldn't get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/#findComment-402562 Share on other sites More sharing options...
marcus Posted November 30, 2007 Share Posted November 30, 2007 Haha. Just remove the includes, and connect to your database, you should be set. Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/#findComment-402564 Share on other sites More sharing options...
hellonoko Posted November 30, 2007 Author Share Posted November 30, 2007 Gave that I try. Page seems to work fine. But where is this backup going? Cant find it anywhere. Running on WAMP btw. <?php include 'dbconnect.php'; $dbname = "idea"; $dbhost = "localhost"; $dbuser = "idea"; $dbpass = "idea"; $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz'; $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile"; system($command); ?> Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/#findComment-402569 Share on other sites More sharing options...
marcus Posted November 30, 2007 Share Posted November 30, 2007 Should go in the same folder. Most likely your connection is wrong. Do: $backupFile = "idea_" . date("Y-m-d-H-i-s") . ".gz"; $command = "mysqldump --opt -h localhost -u root idea | gzip > $backupFile"; system($command); Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/#findComment-402578 Share on other sites More sharing options...
hellonoko Posted November 30, 2007 Author Share Posted November 30, 2007 Nothing. No errors. But not file created either. Quote Link to comment https://forums.phpfreaks.com/topic/79496-backup-mysql-db-with-php/#findComment-402583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.