welaika / wordmove

Multi-stage command line deploy/mirroring and task runner for Wordpress
https://wptools.it/wordmove
MIT License
1.87k stars 165 forks source link

Wrong path in local database after mysql_dump #475

Closed llucps closed 6 years ago

llucps commented 6 years ago

Hi everyone,

Let's see if anyone can help me with this small issue I'm facing.

FYI, my local environment is actually a VPS and the production environment is another hosting provider, so I don't really work on my local machine, so all the transfers/copy go from one server (production, shared hosting) to another server(my VPS) but I guess that shouldn't matter, shouldn't it?

I managed to make everything working, (core, plugins, themes etc. expect the last step which is dump the "production" database into the "local" environment. I quoted production and local because my case is a bit peculiar.

This is my movefile.yml in my "local" environment:

global:
  sql_adapter: wpcli

local:
  vhost: http://www.mydomain.com
  wordpress_path: /var/customers/webs/development/xxxxxx # use an absolute path here

  database:
    name: development2
    user: development2
    password: "xxxxxxxxx" # could be blank, so always use quotes around
    host: localhost

production:
  vhost: http://www.production.com
  wordpress_path: / # use an absolute path here

  database:
    name: productionsql
    user: productionsql
    password: xxxxxxxx
    host: xxxxxxxx.com
    # port: 3308 # Use just in case you have exotic server config
    # mysqldump_options: --max_allowed_packet=1G # Only available if using SSH
    # mysql_options: --protocol=TCP # mysql command is used to import db

  exclude:
    - 'backups/'
    - '.git/'
    - '.gitignore'
    - 'node_modules/'
    - 'bin/'
    - 'tmp/*'
    - 'Gemfile*'
    - 'Movefile'
    - 'movefile'
    - 'movefile.yml'
    - 'movefile.yaml'
    - 'wp-config.php'
    - 'wp-content/*.sql.gz'
    - '*.orig'

  ftp:
     user: xxxxx
     password: xxxxxx
     host: ftp.xxxxx.com
     passive: true

My local vhost is www.mydomain.com (this is obviously an example) so it's not my local machine. The problem I have is after the last step which is dump the mysql database from production to local.. it changes all the references from the production database such as site_url which in production is http://www.production.com for http://var/customers/webs/development/xxxxxx in the local (aka my VPS) database, which is the wordpress_path in my local environment.

Any idea why is this happening? All the rest works, connections, copying themes, core, plugins, it's just this small issue and I have no idea why?. Obviously the wp-cli is installed and working well.

I forgot to mention that I'm using FTP because the "production" server is a shared hosting provider that doesn't allow SSH connection.

Oh another thing... when I setup the movefile.yml be default the local vhost was set as http://vhost.local and I changed it for my real VPS url http://www.mydomain.com. I don't know whether that matters or not.. but I tried with both vhost and the result is the same.

Thanks for your help.

alessandro-fazzi commented 6 years ago

Hello there.

Would you mind to try what is in the main README?

Use the relative FTP path as production.wordpress_path Use the absolute FTP path as production.wordpress_absolute_path (you may need to recover this from the FILE magic constant

Let's see if it can work with that config in :)

llucps commented 6 years ago

Hi,

Sorry, I'm confused. It's not clear where should I try to use those options.. in:

production:
  vhost:
  **wordpress_path:** here?

or

ftp:
     user: xxxxx
     password: xxxxxx
     host: ftp.xxxxx.com
     passive: true
     wordpress_path: here?

I retrieved the FILE global variable which is /home/content/95/7135695/html but I tried to use it on production: wordpress_absolute_path: but that doesn't work.. the / relative path seems to be correct since the FTP connection logs into the wordpress root directory itself.

Also remember the problem is pulling from the production to local (my VPS).

If I try to use wordpress_absolute_path in production, then executing wordmove doctor gives me this error:


▬▬ Using Movefile: ./movefile.yml ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬ Validating movefile section: global ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✓ success | Formal validation passed

▬▬ Validating movefile section: local ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✓ success | Formal validation passed

▬▬ Validating movefile section: production ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✗ error | [/ftp/production.wordpress_absolute_path] key 'production.wordpress_absolute_path:' is undefined.

▬▬ Using Movefile: ./movefile.yml ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬ Checking local database commands and connection ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✓ success | `mysql` command is in $PATH
    ✓ success | `mysqldump` command is in $PATH
    ✓ success | Successfully connected to the MySQL server
    ✓ success | Successfully connected to the database

▬▬ Checking local wp-cli installation ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✓ success | wp-cli is correctly installed
    ✓ success | wp-cli is up to date

▬▬ Checking rsync ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✓ success | rsync is installed at version 3.1.2

▬▬ Checking SSH client ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    ✓ success | SSH command found

Thanks for your help.

llucps commented 6 years ago

OK! I got it!

I had to add the two lines into production: so like this:

production:
  vhost: http://www.production.com
  wordpress_absolute_path: /home/content/95/7135695/html # use an absolute path here
  wordpress_path: /

Thank you for your help !

alessandro-fazzi commented 6 years ago

Oh, really nice! So I guess we can close this one ;)

Best