Using WordMove to mirror sites

I use WordMove to mirror local Wordpress installations and DB data back and forth from my Local development machine to the remote server.

Here’s a sample setup:

  • ssh into your site (right click site name, and select Open SSH)
  • cd /app/public
  • Edit wp-config.php and make sure it has the same table prefix as the remote site, don’t change anything else.
  • Install WordMove: gem install wordmove
  • Create the Movefile by doing: wordmove init
  • Edit the Movefile and add Production (and maybe more environmentes)
  • Pull the remote site, including database and media doing: wordmove pull -all

Here’s a sample Movefile:

local:
  vhost: "http://soderlind.dev"
  wordpress_path: "/app/public" # use an absolute path here

  database:
    name: "local"
    user: "root"
    password: "root"
    host: "localhost"

production:
  vhost: "https://soderlind.no"
  wordpress_path: "/ABSOULUTE/PATH/TO/WORDPRESS" # use an absolute path here

  database:
    name: "wp"
    user: "wp"
    password: "PASSWORD"
    host: "localhost"

  exclude:
    - ".git/"
    - ".gitignore"
    - ".sass-cache/"
    - "node_modules/"
    - "bin/"
    - "tmp/*"
    - "Gemfile*"
    - "Movefile"
    - "wp-config.php"
    - "wp-content/*.sql"

  ssh:
    host: "SSHHOST"
    user: "SSHUSER"
1 Like

I tried to use WordMore with this but kept getting:
sh: mysqldump: command not found

I’m not sire if I needed a path or to run sql somewhere. How did you get around this?

@soderlind I actually sorted this out mostly. I installed a local mysql and got rid of any other mysql installs or apps that had it running. I now have wordmove using my local installs mysqldump, but when it runs I get this error:
mysqldump: Got error: 1049: Unknown database ‘local’ when selecting the database

Hey soderlind,

Any chance you could do a little video tut for us on this workflow?

Thanks in advance :slight_smile:

Ok, late but I was able to make it work.

The important stuff is:

  • Make sure you have the same database prefix as the remote site.
  • Be sure to have all the dependencies required to make WordMove work. That includes having mysql installed in the system and having its executable in your path with the proper permissions. I had to manually add the mysqldump executable to my path. For this, after I installed MySQL in my system, I created a symbolic link (ln -s) from /usr/local/bin/mysqldump to /usr/local/mysql/bin/mysqldump.
  • In the Movefile, in the remote (or production or however you call it) environment, I specified the database host as the IP that Local gives you in the Database tab of the site you created in the GUI.
  • I installed wp cli in my system and changed the sql_adapter line in the Movefile from ‘default’ to ‘wpcli’.
  • Finally, in the wp-config.php I changed the localhost in the "define( ‘DB_HOST’, ‘localhost’) " line for the same IP that Local gives you in the Database tab in GUI and added the port number at then end. It lookes like this:
    define(‘DB_HOST’, ‘192.168.90.200:4002’). We need to make that change or wp-cli won’t be able to connect to the database and replace the urls automatically. In my case, I still had to change the siteurl value manually in the database but that was easy.

After all this, I was able to successfully pull the database with WordMove. The last problem I got in was that wp-cli didn’t changed the siteurl value in the database, so when I tried to access the local domain it redirected me to the remote server and the browser cached this as a 301 redirect. So I had to erase that cache (is not the regular cache you can delete in the privacy settings) and, after also changing hte siteurl value directly in the database with Sequel Pro, I was finally able to visit the local environment.

Hope all this helps/saves someone!

1 Like

Hello,
I am trying to pull a Database from production to local (flywheel) and i am not sure how to deal with the database. It’s not finding the mysql database ( local
mysqldump: Got error: 2002: Can’t connect to local MySQL server through socket). Is there a fix ?
Any pointers would be great ! Thanks

@squaremunkey

Please see:

1 Like

I got the following error

/var/lib/gems/2.1.0/gems/wordmove-2.0.0/lib/wordmove/sql_adapter.rb:44:in `gsub!': 
invalid byte sequence in US-ASCII (ArgumentError)

Fixed it by adding the following to .profile

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
1 Like

I don’t know what Local by Flywheel does to host the MySQL section of these WordPress installs, but I have my own solution with wordmove and I hope other are able to get help with this.

So turns out that for me it’s just impossible to get wordmove to work with primarily the database section… here is a trick to get something.

Assuming all your credentials are correct. Go ahead and do a wordmove push --all. After like 3-4 minutes it will be successful everywhere BUT the database section. Let that be.

Now go to local by flywheel and go to the database of the site you are converting. Click on “Adminer” to open up the database. On the left hand side click on Export.

Make sure that the option is selected as save rather thanopen. At the top you will see a section on the table calledDATABASE. Leave blank. Under tables select the optionDROP + CREATE`. This looks sketch but your local database will be fine. Usually PHPmyadmin is annoying if there is a table that already exists.

Go to your PHPmyadmin in your server and import the file that was just created.

After that go to the wp_options table and replace the url’s of your old site to the new one. Wordmove does this for you if you were able to get the database to work but hey, you are reading this for a reason aren’t you?

Your site should be live. It’s not the most convenient way to do this but beggars can’t be choosers I guess.

I am coming back to this question 2 month from when I posted my solution. When can we get an update on this?

@lewismenelaws,

Can you please share the errors that you’re running into? Does @soderlind’s guide not work for you?

This is the most important step. If you run WordMove on your Mac or PC, you will have to install many more dependencies such as MySQL.

Hi @soderlind, does this still work? I tried gem install wordmove and my terminal says gem: command not found. In fact, ruby isn’t available on my local site at all. @clay can you confirm that is the case?

I’m thinking I might need to install ruby inside my local site. Before I go down this rabbit hole, is that the right thing to do?

Prerequisite ( @clay, this should be added to the post at the top, @blogjunkie this should fix your problem ):

ssh into your site ( I would have created a new site when testing this):

  1. First thing first, run :
apt update
apt upgrade
  1. Add essential packages
apt-get install build-essential git wget rubygems 
  1. WordMove needs ruby 2.4 or newer. First install ruby-install following the guide at https://github.com/postmodern/ruby-install#install
wget -O ruby-install-0.7.0.tar.gz https://github.com/postmodern/ruby-install/archive/v0.7.0.tar.gz
tar -xzvf ruby-install-0.7.0.tar.gz
cd ruby-install-0.7.0/
make install
  1. List supported Rubies and their major versions
ruby-install
  1. Install ruby 2.4.x (was 2.4.7 when I wrote this) in /usr/local
ruby-install --system ruby 2.4.7
  1. Log out of the terminal and ssh into it again

You’ll now have the prerequisites to install WordMove

In case anyone lands on this post and is still struggling to get Wordmove db push/pull working with Local, see here:
https://localbyflywheel.com/community/t/using-mysqldump-with-wordmove/756/6

and here:

https://github.com/welaika/wordmove/issues/552

1 Like