Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am writing a script to take backup of WordPress database through another server If I know ftp and wordpress login details, then how can I download wordpress database from another server.

This is what I am thinking:

  1. As I know ftp then I can see my database setting in wp-config.php .

  2. But my db-host is localhost so how can I connect to database?

I just need a direction to solve my problem.

share|improve this question

migrated from wordpress.stackexchange.com Mar 7 at 19:09

This question came from our site for WordPress developers and administrators.

    
SSH? This has nothing to do with WordPress. –  Wyck Mar 7 at 18:38
    
FTP credentials may not be (and really shouldn't be) able to access the database installation. Localhost just means the same server/machine that the wp-config file is on. Agree with @Wyck that this isn't a WordPress question. You might have better luck on Stack Overflow itself asking a more tightly scoped question about database cloning. –  Andrew Bartel Mar 7 at 19:07
add comment

3 Answers 3

If you are trying to get a backup of your Wordpress database, it may be the easiest option to contact the tech support of your hosting company since they likely have a one click process they can use to provide a backup. Backups are often text files with SQL statements that build the database and insert the data.

Othewise, if you have SSH access, you can use mysqldump found here http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html (assuming it is MySQL) This may not be as easy to understand at first, but may be the best option if tech support is not an option or you do not have control panel access to your site.

If you do not have SSH access and the database is MySQL, you can install the client on your your computer. You can find the client here http://www.mysql.com/products/workbench/ You will still need to contact tech support or use a control panel to allow a connection from your computer. This is not the easiest option, but gives you the most control. If you use this option, localhost must be replaced with the IP address of the server. You will also need port 3306 open at the hosting site.

If you have access to a control panel, then there should be a backup mechanism for the installed backup that will create a single text file with SQL statements that can build the database and insert the data. You will be able to put the file into a directory that you can FTP or HTTP download.

Lastly, if you know it is MySQL, you know what version, and you have access to the database files directly, then if you can stop the database, simply copy the files to your computer. To make work somewhere else, install a compatible version of MySQL, stop the server, and copy the backup files to a new directory. Edit the database location using a client, then restart the server.

I assume this is what you were looking for.

share|improve this answer
add comment

If you have FTP and Wordpress login access there are a couple of way you can go about it.

Focusing on the Wordpress access you might take a look at a few of the database export and management plugins to help you get started. You could have the database saved locally where the install is hosted and pull it via ftp or integrate the code directly into your script.

http://wordpress.org/plugins/wp-dbmanager/

http://wordpress.org/plugins/wp-db-backup/

There are lots more but I can only post 2 links atm.

share|improve this answer
add comment

I think majority servers closed remote connections to databases. but if remote access to database is available:

As I know ftp then I can see my database setting in wp-config.php

If it's set to locolhost, use server IP or Hostname.

But if it's other Hostname you need to use that or that Hostname IP's. You can check this Automatically by simple IF...else.. in PHP.

Also you can find automatic backup plugins for WordPress Here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.