Backup All Wordpress Databases On a Server

This simple script looks in a specified directory (and its subdirectories), the webserver document root preferably, for wp-config.php files. When it finds a file it parses it to extract the variables DB_NAME, DB_USER, DB_PASSWORD and DB_HOST inside the file and then connects to the database and dump it using mysqldump into a text file compressed using gzip. All the backups are placed in another user specified diretory where they are suffixed with the current date in %Y-%m-%d format.

Some of the advantages are that you don’t need to specify anything on beforehand since it will automatically find all the Wordpress installations in the document root and back up their databases. Also, if a user or administrator changes the settings then the script will use the new values since it does not save them anywhere, it reads them straight from the configuration file on every run.

It should probably be extended with some error handling but right now it’s simple and works fine.

7 Responses to “Backup All Wordpress Databases On a Server”

  1. mrben Says:

    Presumably it wouldn’t be too hard to get it to drop into subdirectories by one level to look for the files? All the wordpress installs on jedimoose.org are in their own subdirectories, but if it can drop a level, then this would be an excellent tool for us.

  2. nlindblad Says:

    I probably wasn’t clear enough, it does a recursive check of course, hence, it’d find everything in your whole directory structure.

  3. AusCoder » Blog Archive » Automatically backup all your WordPress blogs Says:

    […] script is a php port of the bash script by Niklas Lindblad with error handling, and database connection pre-tests, it also has very good logging for easy […]

  4. John Says:

    Fantastic script. Obviously a believer in KISS Engineering! Thanks for sharing!

  5. bondage novels Says:

    bondage novels…

    Value source for bondage novels….

  6. free gay newsletters Says:

    free gay newsletters…

    Title of free gay newsletters…

  7. bdsm term serving Says:

    bdsm term serving…

    Relevant links for bdsm term serving….

Leave a Reply