- Notifications
You must be signed in to change notification settings - Fork171
Multi-stage command line deploy/mirroring and task runner for Wordpress
License
welaika/wordmove
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Wordmove is a command line tool that lets you automatically mirror local WordPressinstallations and DB data back and forth from your local development machine toone or more remote servers.
Wordmove has also a neathook system which enables you to run arbitrary commandsbefore and after push/pull actions. Local and remote commands are both supported (remoteones only on SSH protocol).
FTP support development has been discontinued, thus not all features are granted when using this protocol.
Wordmove is developed in ruby and packaged and distributed as a gem.
To install:
gem install wordmove
And to update:
gem update wordmove
You can read more about ruby gems ecosystem on the official sitehttps://rubygems.org/.
Wordmove acts as automation glue between tools you already have and love. These are its peer dependencies whichyou need to have installed and executable through your system $PATH:
Program | Mandatory? |
---|---|
rsync | Yes for SSH protocol |
mysql | Yes |
mysqldump | Yes |
wp-cli | Yes by default, but configurable |
lftp | Yes, for FTP protocol |
Wordmove also expect that the remote server will have the following commands:gzip
,nice
,mysql
,rsync
. All of these should be always present by default on any WordPress hosting.
> wordmove helpCommands: wordmove --version, -v # Print the version wordmove doctor # Do some local configuration and environment checks wordmove help [TASK] # Describe available tasks or one specific task wordmove init # Generates a brand new movefile.yml wordmove list # List all environments and vhosts wordmove pull # Pulls WP data from remote host to the local machine wordmove push # Pushes WP data from local machine to remote host
Move inside the WordPress folder and usewordmove init
to generate a newmovefile.yml
and edit it with your settings. Read the next paragraph for more info.
See the wiki article:Usage and flags explained for more info.
You can define multiple remote environments in yourmovefile.yml
, such as production, staging, etc. Every first level key in the YAML other than the defaults and mandatoryglobal
andlocal
will be interpreted as a remote environment.
Use-e
withpull
orpush
to run the command on the specified environment.
For example:wordmove push -e staging -d
will push your local database to the staging environment.
We warmlyrecommend to read the wiki article:Multiple environments explained
You can configure Wordmove creating amovefile.yml
. That's a YAML file with local and remote host(s) infos:
global:sql_adapter:wpclilocal:vhost:http://vhost.localwordpress_path:/home/john/sites/your_site# use an absolute path heredatabase:name:database_nameuser:userpassword:passwordhost:localhost# paths: # you can customize wordpress internal paths# wp_content: wp-content# uploads: wp-content/uploads# plugins: wp-content/plugins# themes: wp-content/themes# languages: wp-content/languagesproduction:vhost:http://example.comwordpress_path:/var/www/your_site# use an absolute path heredatabase:name:database_nameuser:userpassword:passwordhost:host# port: 3308 # Use just in case you have exotic server config# mysqldump_options: --max_allowed_packet=50MB # Only available if using SSH# mysql_options: --protocol=TCP # Only available if using SSHexclude: -'.git/' -'.gitignore' -'node_modules/' -'bin/' -'tmp/*' -'Gemfile*' -'Movefile' -'movefile' -'movefile.yml' -'movefile.yaml' -'wp-config.php' -'wp-content/*.sql.gz' -'*.orig'ssh:host:hostuser:user# hooks: # Remote hooks won't work with FTP# push:# before:# - command: 'echo "do something"'# where: local# raise: false # raise is true by default# after:# - command: 'echo "do something"'# where: remote# pull:# before:# - command: 'echo "do something"'# where: local# raise: false# after:# - command: 'echo "do something"'# where: remote
We warmlyrecommend to read the wiki articles
to understand more about supported configurations.
Wordmove allows the use of environment variables in your movefiles.This is useful in order to protect sensitive variables and credentials, as well as make it easy to share movefiles between your team.
Environment variables are written using theERB tags syntax:
"<%= ENV['YOUR_SECRET_NAME'] %>"
Environment variables can be set up using two methods:
# bashexport PROD_DB_USER="username" PROD_DB_PASS="password"# fishset --export --global PROD_DB_USER"username";set --export --global PROD_DB_PASS"password"
Wordmove supports thedotenv module.
Simply create a.env
file next to your movefile structured as follows:
PROD_DB_USER="username"PROD_DB_PASS="password"
Wordmove will take care of loading the file and making the environment variables ready to be used in your configuration file.
You may also use.env.{environmentname}
, but this is discouraged.
Using the ERB syntax described above, write your movefile as follows:
production:database:user:"<%= ENV['PROD_DB_USER']%>"password:"<%= ENV['PROD_DB_PASS']%>"
You can use system variables to configure your movefile.
For example:
local:vhost:"http://wordpress-site.localhost"wordpress_path:"<%= ENV['HOME']%>/[wordpress directory path]/"# wordpress_path will be substituted with /home/user_name/[wordpress directory path]
OS X and Linux are fully supported.
See theWindows (un)support disclaimer
We have a docker image bringing the latest Wordmove's version with autobuild on new releases.
- You need
rsync
on your machine; as far as we know it's already installed on OS X and Linux. - To use your SSH public key for authentication, just delete the
production.ssh.password
field in yourmovefile.yml
. Easy peasy. - writing the password inside
movefile.yml
was and is somewhat supported, butwe discourage this practice in favor of password-less authentication with pub key. Readhere for old informations.
- You need to install
lftp
on your machine. See community wiki article:Install lftp on OSX yosemite). - 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 - if you want to specify a passive FTP connection add to the YAML config a
production.ftp.passive
flag and set it totrue
.
FTP support development isdiscontinued, but it's always there.
Sice version 3.2.0 SFTP is fully supported, with same functionalities as FTP, throughproduction.ftp.scheme
configuration. More information found in the wiki.
Push and pull actions on files will perform amirror operation. Please, keepin mind that to mirror means to transfer new/updated filesand remove filesfrom destination if not present in source.
This means that if you have files/directories on your remotes which you mustpreserve, youmust exclude those in your movefile.yml, or they will bedeleted.
We're glad you asked! We basically upload via FTP a PHP script that performs the variousimport/export operations. This script then gets executed via HTTP. Don't worrytoo much about security though: the script is deleted just after the usage,and can only be executed bywordmove
, as each time it requires a pre-sharedone-time-password to be run.
Wordmove1.3.1
has been removed fromrubygems
due to a bug with FTP deploying system. If you areusing this version, please update soon (gem update wordmove
).
VisitWordpress Tools.
- The dump script is the
MYSQL-dump
PHP package by David Grudl - The import script used is theBigDump library
Please, read thecontributor guide.
Feel free to open a discussion issue about contribution if you need more info.
made with ❤️ and ☕️ byweLaika
About
Multi-stage command line deploy/mirroring and task runner for Wordpress