WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

the bigger question is: How to have a beta (test) site and production, and switch between them so easily that a user can do it.

I wrote a script that does the move. Here's what the script does:

1. saves the target wp-config DB settings
2. dumps source_DB, with --add-drop-table --add-drop-database 
3. replaces all http://source/ with http://target in dump_DB.sql
4. loads source_DB.sql in Target_DB
5. (there is no cache plugin in either sites)
6. rsync --delete /source/path/ to /target/path
7. chown -R /target/path  with the correct ownership

The script works perfectly. the source-site is practically identical to the target-site. The files are md5-identical between the srouce and target (except wp-config.php).

BUT! (here's are questions)

  • The main menu is "forgotten". I have to manually go to "menus" and select the main-menu from the drop-down box. it happens each time i switch these websites. How can that be, if the database is copied 1:1 ? Could it be that the menu is related to domain URL somehow?

  • the background preference (controlled by "simplify" theme") is forgotten. I have to manually select the background images from existing images.

  • Is there a better way to switch test-site <> production site without all this hassle? I Just want to have a test site and to switch DNS entries. My posts dont travel over the internet, so I dont need absolute URLS. changing "hosts" file solution is not acceptable for admin end-user.

share|improve this question

There's a set of tutorials on how to deploy WordPress (source and DB) using Capistrano.

Part 1 | Part 2 | Part 3

Capistrano allows you to deploy WordPress installations from the command line. It was initially developed for Ruby on Rails apps, but it has the capability to deploy many other systems, apparently.

There's information in the tutorials on:

  • setting up Capistrano
  • "capifying" WordPress
  • deploying to multiple servers
    (so you can, for instance, have test/staging/production environments)
  • using Capistrano to manage your WP databases (including backup & restore)

I haven't had a chance to try it yet, but I'm really itching to.

share|improve this answer
Lone link is considered a poor answer (see FAQ) since it is meaningless by itself and target resource is not guaranteed to be alive in the future. Please try to include at least summary of information you are linking to. – Rarst May 29 '13 at 14:42
Updated my answer. If it's still insufficient, let me know and I'll edit further or remove it. – Pat J May 29 '13 at 15:55
thanks! will check it out. – Berry Tsakala May 29 '13 at 20:17

You cannot just do a plain text string replacement on database dump - that breaks any serialized data, that contains string being replaced, and WordPress uses that plenty.

Only use replacement tools with support of serialized data, such as Search-Replace-DB.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.