dev-master
9999999-dev https://github.com/dword-design/wp-cli-migrate-commandWP-CLI command to transfer a database or uploads from one connection to another.
MIT
 Wallogit.com
                    
                    2017 © Pedro Peláez
                         Wallogit.com
                    
                    2017 © Pedro Peláez
                    
                    
                    
                    
                
                
            
WP-CLI command to transfer a database or uploads from one connection to another.
This command allows to migrate databases and upload directories across wordpress installations. URL replacements can be configured., (*1)
Since the package index of WP-CLI is currently on hold, the package has to be installed by hand:, (*2)
$ cd ~/.wp-cli/packages/ $ composer require dword-design/wp-cli-migrate-command
Configure your database connections in wp-cli.yml:, (*3)
databases:
  @local:
    host: localhost
    database: local_db_name
    user: local_db_user
    password: local_db_password
    domain-prefix: '//webiste.dev'
  @live:
    host: myserver.de
    database: live_db_name
    user: live_db_user
    password: live_db_password
    domain-prefix: '//www.website.de'
  ...
For upload migration, configure your SSH aliases in wp-cli.yml:, (*4)
@live: ssh: user@myserver.de path: www
Note that no entry is needed for local connections. In this case, the current directory is taken., (*5)
Lastly, if the upload directories differ from wp-content/uploads, configure them for each SSH alias:, (*6)
uploads: @local: 'some/special/dir' @live: 'another/special/dir'
If there is no corresponding SSH alias, the uploads folder is assumbed to be relative to the current directory., (*7)
Execute the migrate command:, (*8)
$ wp migrate <db|up> @sourceAlias @targetAlias
wp migrate db @sourceAlias @targetAlias migrates the database from a source database to a target database. Occurrence of the domain-prefix are replaced. Beware that the database is dropped and recreated on the target system., (*9)
wp migrate up @sourceAlias @targetAlias migrates the uploads folder via rsync. Beware that files are deleted on the target system that do not exist on the source system., (*10)
wp migrate @sourceAlias @targetAlias executes both tasks., (*11)
WP-CLI command to transfer a database or uploads from one connection to another.
MIT