# Using WordMove to mirror sites

**URL:** <https://community.localwp.com/t/using-wordmove-to-mirror-sites/856>\
**Category:** Workflow\
**Created:** [February 24, 2017, 12:45pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856 "2017-02-24T12:45:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![soderlind](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/soderlind/32/24675_2.png) [@soderlind](https://community.localwp.com/u/soderlind)\
**Post date:** [February 24, 2017, 12:45pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/1 "2017-02-24T12:45:20Z")

</div>

I use [WordMove](http://welaika.github.io/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](https://github.com/welaika/wordmove/wiki/Multiple-environments-explained))
- 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"
```

---

<div class="post-metadata">

**Author:** ![digi57](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@digi57](https://community.localwp.com/u/digi57)\
**Post date:** [March 16, 2017, 4:02pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/2 "2017-03-16T16:02:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![digi57](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@digi57](https://community.localwp.com/u/digi57)\
**Post date:** [March 18, 2017, 1:15am UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/3 "2017-03-18T01:15:47Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![dyl4n](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@dyl4n](https://community.localwp.com/u/dyl4n)\
**Post date:** [May 25, 2017, 11:38pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/4 "2017-05-25T23:38:45Z")

</div>

Hey soderlind,

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

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![oquirozm](https://avatars.discourse-cdn.com/v4/letter/o/e9bcb4/32.png) [@oquirozm](https://community.localwp.com/u/oquirozm)\
**Post date:** [August 3, 2017, 12:12am UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/5 "2017-08-03T00:12:40Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![squaremunkey](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@squaremunkey](https://community.localwp.com/u/squaremunkey)\
**Post date:** [August 8, 2017, 6:21pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/7 "2017-08-08T18:21:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![clay](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/clay/32/8248_2.png) [@clay](https://community.localwp.com/u/clay)\
**Post date:** [August 9, 2017, 7:12pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/8 "2017-08-09T19:12:42Z")

</div>

@squaremunkey

Please see:

> [@oquirozm](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![soderlind](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/soderlind/32/24675_2.png) [@soderlind](https://community.localwp.com/u/soderlind)\
**Post date:** [August 18, 2017, 11:13am UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/9 "2017-08-18T11:13:49Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![lewismenelaws](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/lewismenelaws/32/3312_2.png) [@lewismenelaws](https://community.localwp.com/u/lewismenelaws)\
**Post date:** [April 23, 2018, 10:36pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/10 "2018-04-23T22:36:13Z")

</div>

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 than`open`. At the top you will see a section on the table called`DATABASE`. Leave blank. Under tables select the option`DROP + 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.

---

<div class="post-metadata">

**Author:** ![lewismenelaws](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/lewismenelaws/32/3312_2.png) [@lewismenelaws](https://community.localwp.com/u/lewismenelaws)\
**Post date:** [June 23, 2018, 9:35pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/11 "2018-06-23T21:35:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![clay](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/clay/32/8248_2.png) [@clay](https://community.localwp.com/u/clay)\
**Post date:** [June 26, 2018, 4:23pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/12 "2018-06-26T16:23:53Z")

</div>

@lewismenelaws,

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

> [@soderlind](#):
>
> - ssh into your site (right click site name, and select Open SSH)

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.

---

<div class="post-metadata">

**Author:** ![blogjunkie](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/blogjunkie/32/4511_2.png) [@blogjunkie](https://community.localwp.com/u/blogjunkie)\
**Post date:** [September 23, 2019, 1:12am UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/13 "2019-09-23T01:12:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![soderlind](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/soderlind/32/24675_2.png) [@soderlind](https://community.localwp.com/u/soderlind)\
**Post date:** [September 23, 2019, 11:16am UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/14 "2019-09-23T11:16:53Z")

</div>

**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 :

```auto
apt update
apt upgrade

```

1. Add essential packages

```auto
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](https://github.com/postmodern/ruby-install#install)

```auto
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

```auto
ruby-install

```

1. Install ruby 2.4.x (was 2.4.7 when I wrote this) in /usr/local

```auto
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

---

<div class="post-metadata">

**Author:** ![optimystery](https://avatars.discourse-cdn.com/v4/letter/o/0ea827/32.png) [@optimystery](https://community.localwp.com/u/optimystery)\
**Post date:** [December 18, 2019, 3:47pm UTC](https://community.localwp.com/t/using-wordmove-to-mirror-sites/856/16 "2019-12-18T15:47:09Z")

</div>

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](https://localbyflywheel.com/community/t/using-mysqldump-with-wordmove/756/6)

and here:

[https://github.com/welaika/wordmove/issues/552](https://github.com/welaika/wordmove/issues/552)
