dev-master
9999999-devWordpress sync commandline tool
MIT
The Requires
v1.0.1
1.0.1.0Wordpress sync commandline tool
MIT
The Requires
v1.0
1.0.0.0Wordpress sync commandline tool
The Requires
Wordpress sync commandline tool
A command line tool for local WordPress development., (*1)
wpsh
is a command line tool we use to sync the database and uploaded files from a remote (PRODUCTION) WordPress install to a local (DEVELOPMENT) install., (*2)
It was inspired by Drupal's drush
tool., (*3)
You will need:, (*4)
composer
installed locally (for installation).mysql
needs to be installed remotely.mysql
and rsync
need to be installed locally and in your path.Install globally using composer., (*5)
$ composer global require gwa/wpsh
Test that wpsh
is installed:, (*6)
$ wpsh
You should see some usage help output., (*7)
Site "aliases" contain the configuration for a site, either remote or local. wpsh
looks for site aliases in ~/.wpsh
., (*8)
First create the directory in your HOME directory., (*9)
$ mkdir ~/.wpsh
Create a file called in ~/.wpsh
called alias.[mysite].php
., (*10)
mysite
can contain alphanumeric characters, hyphens and periods., (*11)
<?php // File: ~/.wpsh/alias.mysite.php return [ // The production server // '@mysite.prod' => [ // SSH configuration 'remote' => [ 'host' => '123.255.12.123', 'user' => 'username', // Path to a SSH key file // 'identity' => '~/.ssh/custom_rsa', ], // Absolute paths 'path' => [ // The base directory 'base' => '/var/www/mysite', // Path to a custom MySQL cnf file 'cnf' => '~/mysql_cnf/mysite.cnf', // Path to a custom wp dir, relative to base // 'wp' => '', // Path to a custom uploads dir, relative to base // 'uploads' => 'wp-content/uploads', ], // Database settings 'db' => [ // Name of the database 'database' => 'dbname' ], // Other settings 'settings' => [ 'siteurl' => 'http://www.example.com', // Set a custom `home` path. Defaults to siteurl. // 'home' => 'http://www.example.com/wp', ] ], // The local development copy // Settings as above, but without `remote` // '@mysite.local' => [ 'path' => [ 'base' => '/path/local/server/wordpress', ], 'db' => [ 'database' => 'dbname', ], 'settings' => [ 'siteurl' => 'http://mysite.local', ] ], ];
We use cnf
files to store MySQL credentials., (*12)
You can save these in one of the default paths (see MySQL docs), or in a custom path that is defined in the site alias' cnf
path., (*13)
Example:, (*14)
[client] user=mysqluser password="pa$$word" host=127.0.0.1 port=3306
The following commands are available., (*15)
sa
Lists available aliases., (*16)
$ wpsh sa
mysqldump
Creates a mysql dump file., (*17)
$ wpsh mysqldump [@alias] > /path/to/outfile.sql
mysqlsync
Syncs DB from @alias1 to @alias2., (*18)
Updates settings and URLs in posts with the local settings and URLs., (*19)
$ wpsh mysqlsync [@alias1] [@alias2]
rsync
Syncs uploads from @alias1 to @alias2., (*20)
$ wpsh rsync [@alias1] [@alias2]
[ ] Provide hook mechanism for custom scripts / MySQL queries to be executed after sync., (*21)
Wordpress sync commandline tool
MIT
Wordpress sync commandline tool
MIT
Wordpress sync commandline tool