lavmeiker / capistrano-wpcli Goto Github PK
View Code? Open in Web Editor NEWProvides command line tools to facilitate Wordpress deploy.
License: MIT License
Provides command line tools to facilitate Wordpress deploy.
License: MIT License
In my production server, I can't install stuff globally. Because of that, in my deploy/production.rb
file, I have the following config:
SSHKit.config.command_map[:composer] = "/home/web720/composer.phar"
This is respected by capistrano-wpcli
, but unfortunately it is used the same way on local as well, which results in following error for me:
| => bundle exec cap production wpcli:uploads:rsync:pull
INFO [29d88580] Running /usr/bin/env rsync -avz --rsh=ssh --progress [email protected]:/www/itvar.cz/wwwroot/www/shared/web/app/uploads/ web/app/uploads/ as Cibulka@localhost
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Command::Failed: rsync exit status: 65280
rsync stdout: Nothing written
rsync stderr: ssh: connect to host 81.91.83.149 port 22: Operation timed out
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [receiver=2.6.9]
Tasks: TOP => wpcli:uploads:rsync:pull
(See full trace by running task with --trace)
Is it possible to make capistrano-wpcli
use different command on production (/home/web720/composer.phar
) and development (composer
)?
Thanks in advance!
Hello,
When I try to use the wpcli:db:pull
command to dump the remote database, I always end up having this issue :
gunzip -c var/dump/wpcli_database.sql.gz > var/dump/wpcli_database.sql
Specified filename cannot be found
Or something similar (original error in French).
This is triggered by the following line
If I run the exact same command from my shell, everything goes well.
I'm using Windows 10 with Gitbash to connect over SSH on a Linux server. No dev
role is configured.
Hello again!
making this gem work is a little challenging for me, as I use shared hosting with some extra security layers. Here's my first issue:
| => bundle exec cap production wpcli:uploads:rsync:pull
INFO[f43ef1a7] Running /usr/bin/env rsync -avz --rsh=ssh [email protected]:/www/itvar.cz/wwwroot/www/shared/web/app/uploads/ web/app/uploads/ on localhost
cap aborted!
SSHKit::Command::Failed: rsync exit status: 65280
rsync stdout: Nothing written
rsync stderr: ssh: connect to host 81.91.83.149 port 22: Operation timed out
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [receiver=2.6.9]
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:56:in `block in _execute'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:37:in `tap'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:37:in `_execute'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:26:in `execute'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:34:in `block (6 levels) in <top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:14:in `instance_exec'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:14:in `run'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/dsl.rb:10:in `run_locally'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:33:in `block (5 levels) in <top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:32:in `each'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:32:in `block (4 levels) in <top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bin/cap:23:in `load'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bin/cap:23:in `<main>'
Tasks: TOP => wpcli:uploads:rsync:pull
(See full trace by running task with --trace)
I assume that this error is pops up because my host requires port 2222 for SSH connections. I have this specified inside my deploy.rb
config file like this -
set :ssh_options, {
keys: ['~/.ssh/id_rsa'],
port: 2222
}
Capistrano-wpcli
use a port number of my config? Thanks!Hello there,
I followed the README and got the gem installed, it's available, however, when I try to run cap production wpcli:db:pull
, I get
cap aborted!
Don't know how to build task 'wpcli:db:pull' (see --tasks)
I set up some of the paths in production.rb, the server has "wp" as a link to wp-cli.phar, and it runs fine when I try it manually.
What am I missing?
Thanks.
Update: I have a feeling this is not compatible with later Capistrano 3 versions. Maybe it worked at some point, but now it's not even registering its tasks.
★ Update2: Capistrano 3.8 is loading lib/capistrano-wpcli.rb
✨, which is empty. I just migrated the contents of lib/capistrano/wpcli.rb
and updated the path:
# Load all tasks
files = Dir[File.join(File.dirname(__FILE__), 'capistrano/tasks', '*.rake')]
files.each do |file|
load file
end
It is now aware of the wpcli tasks.
I am using bedrock, I can sync database without problem except the uploads folder. I do not set :wpcli_local_uploads_dir and :wpcli_remote_uploads_dir since they are optional.
Hello I have a Wordpress Bedrock Setup and deploy it to my staging server + run composer install.
This all works fine.
But when i want to rsync my uploads i get this error:
$ bundle exec cap staging wpcli:uploads:rsync:pull --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
[Deprecation Notice] Future versions of Capistrano will not load the Git SCM
plugin by default. To silence this deprecation warning, add the following to
your Capfile after `require "capistrano/deploy"`:
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
** Invoke wpcli:uploads:rsync:pull (first_time)
** Execute wpcli:uploads:rsync:pull
00:00 wpcli:uploads:rsync:pull
01 rsync -avz --rsh=ssh --progress -e 'ssh -p 22' [email protected]:/var/www/vhosts/myuser.at/br-be.staging.myuser.at/wp_bedrock/shared/web/app/uploads/ web/app/uploads/
cap aborted!
Errno::ENOENT: No such file or directory - ( export PATH="/usr/bin:/var/www/vhosts/myuser.at/.phpenv/shims:/opt/plesk/phpenv/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/opt/plesk/node/16/bin" WP_ENV="staging" ; /usr/bin/env rsync -avz --rsh=ssh --progress -e 'ssh -p 22' [email protected]:/var/www/vhosts/myuser.at/br-be.staging.myuser.at/wp_bedrock/shared/web/app/uploads/ web/app/uploads/ )
C:/Ruby32-x64/lib/ruby/3.2.0/open3.rb:222:in `spawn'
C:/Ruby32-x64/lib/ruby/3.2.0/open3.rb:222:in `popen_run'
C:/Ruby32-x64/lib/ruby/3.2.0/open3.rb:103:in `popen3'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/sshkit-1.21.5/lib/sshkit/backends/local.rb:44:in `execute_command'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
<internal:kernel>:90:in `tap'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:80:in `execute'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-wpcli-0.1.5/lib/capistrano/tasks/wpuploads.rake:43:in `block (6 levels) in <top (required)>'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/sshkit-1.21.5/lib/sshkit/backends/abstract.rb:31:in `run'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-3.18.0/lib/capistrano/dsl.rb:76:in `run_locally'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-wpcli-0.1.5/lib/capistrano/tasks/wpuploads.rake:39:in `block (5 levels) in <top (required)>'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-wpcli-0.1.5/lib/capistrano/tasks/wpuploads.rake:38:in `each'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-wpcli-0.1.5/lib/capistrano/tasks/wpuploads.rake:38:in `block (4 levels) in <top (required)>'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/airbrussh-1.5.0/lib/airbrussh/rake/context.rb:58:in `execute'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-3.18.0/lib/capistrano/application.rb:14:in `run'
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/capistrano-3.18.0/bin/cap:3:in `<top (required)>'
C:/Ruby32-x64/bin/cap:25:in `load'
C:/Ruby32-x64/bin/cap:25:in `<main>'
Tasks: TOP => wpcli:uploads:rsync:pull
Maybe the reason for this is that i am on windows and do not have rsync installed.
The path for rsync /var/www/vhosts/myuser.at/br-be.staging.myuser.at/wp_bedrock/shared/web/app/uploads/ exists on the remote server and web/app/uploads also exists on my local machine.
Running 'bundle exec cap staging wpcli:run["core version"]' works great.
Any ideas would be great. Thanks in advance
Hi!
I want to set wpcli_args on the wp db import. E.g. wp db import --skip-plugins.
Is this possible atm?
Hey there. Running into issues using this with Bedrock.
In my appropriate areas - config/deploy/staging.rb I have my remote and local url set with the following syntax:
set :wpcli_remote_url, 'http://staging.domain.com/'
set :wpcli_local_url, 'http://local.dev/'
I have the bundle installed by adding it to my Gemfile and Capfile.
When I run the command wpcli:db:push
I get the following error:
INFO[8c1cb844] Running /usr/bin/env wp db export - | gzip > /tmp/wpcli_database.sql.gz on localhost INFO[8c1cb844] Finished in 0.006 seconds with exit status 0 (successful). INFOUploading /tmp/wpcli_database.sql.gz 100.0% INFO[915b8d7b] Running /usr/bin/env gunzip < /tmp/wpcli_database.sql.gz | wp db import - on new.domain.com cap aborted! SSHKit::Runner::ExecuteError: Exception while executing on host new.domain.com: gunzip exit status: 255 gunzip stdout: Nothing written gunzip stderr: PHP Warning: require_once(/srv/www/new.domain.com/releases/20141024185203/vendor/autoload.php): failed to open stream: No such file or directory in phar:///usr/bin/wp/php/WP_CLI/Runner.php(615) : eval()'d code on line 6 PHP Fatal error: require_once(): Failed opening required '/srv/www/new.domain.com/releases/20141024185203/vendor/autoload.php' (include_path='phar:///usr/bin/wp/vendor/phpunit/php-text-template:phar:///usr/bin/wp/vendor/phpunit/phpunit-mock-objects:phar:///usr/bin/wp/vendor/phpunit/php-timer:phar:///usr/bin/wp/vendor/phpunit/php-token-stream:phar:///usr/bin/wp/vendor/phpunit/php-file-iterator:phar:///usr/bin/wp/vendor/phpunit/php-code-coverage:phar:///usr/bin/wp/vendor/phpunit/phpunit:phar:///usr/bin/wp/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear') in phar:///usr/bin/wp/php/WP_CLI/Runner.php(615) : eval()'d code on line 6 /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in
exit_status='
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in block (5 levels) in _execute' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in
call'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in do_request' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in
channel_request'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in dispatch_incoming_packets' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in
preprocess'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in process' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in
block in loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in loop' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in
loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in wait' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in
block (3 levels) in _execute'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in call' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in
do_open_confirmation'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in channel_open_confirmation' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in
dispatch_incoming_packets'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in preprocess' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in
process'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in block in loop' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in
loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in loop' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in
block (2 levels) in _execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in with_ssh' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in
block in _execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in tap' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in
_execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in execute' /Library/Ruby/Gems/2.0.0/gems/capistrano-wpcli-0.0.9/lib/capistrano/tasks/wpdb.rake:65:in
block (5 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in within' /Library/Ruby/Gems/2.0.0/gems/capistrano-wpcli-0.0.9/lib/capistrano/tasks/wpdb.rake:64:in
block (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in instance_exec' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in
run'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in block (2 levels) in execute' SSHKit::Command::Failed: gunzip exit status: 255 gunzip stdout: Nothing written gunzip stderr: PHP Warning: require_once(/srv/www/new.domain.com/releases/20141024185203/vendor/autoload.php): failed to open stream: No such file or directory in phar:///usr/bin/wp/php/WP_CLI/Runner.php(615) : eval()'d code on line 6 PHP Fatal error: require_once(): Failed opening required '/srv/www/new.domain.com/releases/20141024185203/vendor/autoload.php' (include_path='phar:///usr/bin/wp/vendor/phpunit/php-text-template:phar:///usr/bin/wp/vendor/phpunit/phpunit-mock-objects:phar:///usr/bin/wp/vendor/phpunit/php-timer:phar:///usr/bin/wp/vendor/phpunit/php-token-stream:phar:///usr/bin/wp/vendor/phpunit/php-file-iterator:phar:///usr/bin/wp/vendor/phpunit/php-code-coverage:phar:///usr/bin/wp/vendor/phpunit/phpunit:phar:///usr/bin/wp/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear') in phar:///usr/bin/wp/php/WP_CLI/Runner.php(615) : eval()'d code on line 6 /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in
exit_status='
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in block (5 levels) in _execute' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in
call'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in do_request' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in
channel_request'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in dispatch_incoming_packets' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in
preprocess'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in process' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in
block in loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in loop' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in
loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in wait' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in
block (3 levels) in _execute'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in call' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in
do_open_confirmation'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in channel_open_confirmation' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in
dispatch_incoming_packets'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in preprocess' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in
process'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in block in loop' /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in
loop'
/Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in loop' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in
block (2 levels) in _execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in with_ssh' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in
block in _execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in tap' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in
_execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in execute' /Library/Ruby/Gems/2.0.0/gems/capistrano-wpcli-0.0.9/lib/capistrano/tasks/wpdb.rake:65:in
block (5 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in within' /Library/Ruby/Gems/2.0.0/gems/capistrano-wpcli-0.0.9/lib/capistrano/tasks/wpdb.rake:64:in
block (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in instance_exec' /Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in
run'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in block (2 levels) in execute' Tasks: TOP => wpcli:db:push (See full trace by running task with --trace
Thanks for your work, really great stuff!
I am pushing my db to both staging and production and it searches and replaces the url (from :wpcli_local_url / :wpcli_remote_url) just fine. However I have some absolute paths that I would like to search and replace as well. Is there support to handle cases like this?
Somehow under some circumstances the wpcli:uploads:rsync:* command does not invoke custom set ports for the rsync command.
See: #28 (comment)
Is there a way we can merge the databases before db:pull and db:push tasks. thanks
Hi guys!
I'm experiencing some trouble with backup:remote function. The exported remote .sql.gz file in /tmp folder is perfect, but when download! command downloads the db dump file, locally I find a 15KB file named db_stage_timestamp.sql.gz that's corrupted.
When I try to extract the file with a double click on it, the Mac's Compression Utility returns me a file with a .sql.gz 2.cpgz extension, and if i try to extract the .sql.gz 2.cpgz file, the Mac's Compression Utility returns me a file with a .sql 2.gz extension and so on.
I also tried to extract it with gunzip command, but returns me that error: gunzip: db_stage_timestamp.sql.gz: not in gzip format
I think that the problem isn't the download! command itself, but maybe the Pathname.new() or something else in the backup:remote function, that's because push and pull (that use the downlaod! command) work well without any kind of problem.
Mac OS X version: 10.11.5
Rbenv version: 1.0.0
Ruby version: 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
Here you can find all the gems installed on my Mac:
bigdecimal (1.2.8)
bundler (1.12.5)
capistrano (3.4.1)
capistrano-wpcli (0.1.2)
colorize (0.8.0)
i18n (0.7.0)
io-console (0.4.5)
json (1.8.3)
net-scp (1.2.1)
net-ssh (3.2.0)
psych (2.0.17)
rake (11.2.2)
rdoc (4.2.1)
sshkit (1.7.1)
Any suggestion? Thank you.
wpcli_args
makes it possible to search & replace a database for a Multisite network. For example:
set :wpcli_args, '--skip-columns=guid --network --url=http://www.example.dev'
However, you need to pass --url
to properly search & replace in a multisite network. This URL depends on your action: pushing or pulling.
So you need to change the configuration files every time you want to push or pull.
Would it be possible to include this argument in the actual command? For example:
cap staging wpcli:db:push --url=http://www.example.dev
It's be great to pass an optional flag (cap staging wpcli:db:push --backup="./backups/"
) to save a copy of the sql dump before deleting it, which would also be accessible via a separate taske wpcli:db:backup
.
When running:
cap production wpcli:run["help"]
Returns:
no matches found: wpcli:run["help"]
added a line in my PR
upload! fetch(:wpcli_local_db_file), fetch(:wpcli_local_db_file)
Hey @lavmeiker,
Really like what you have done! Thanks for this gem. I have a question. Is there a way to dump
a database rather than push
or pull
? For instance, I want my site to run a backup whenever I deploy just in case.
Also, is there more examples? If there isn't could I commit some to your .README
?
Thanks
Love this plugin BTW. Thanks for the hard work.
I ran into an issue with Vagrant being my local dev environment and using the server ... :roles%w{dev}
and :dev_path
settings you defined at the bottom of the README within deploy.rb.
Using Capistrano 3.6.1 and the current version of this plugin.
Basically when I attempt to run cap <stage> deploy
it tries to deploy to my remote stage and the vagrant box simultaneously and errors out. However, when I set that server to :no_release, true
it works again.
I created a development.rb file in the deploy folder so I could use the wpcli:run
command from outside the box but I can't run that command from outside the box because it is looking for a release_path. Since my vagrant box isn't a release, would you recommend I take another approach or create a pull request to modify that task for wpcli:run
?
My idea would be to modify it for the dev role something like this:
task :run, :command do |t, args|
args.with_defaults(:command => :help)
on roles(:dev) do
within fetch(:dev_path) do
execute :wp, args[:command], fetch(:wpcli_args)
end
end
on release_roles(fetch(:wp_roles)) do
within release_path do
execute :wp, args[:command], fetch(:wpcli_args)
end
end
end
I haven't tested this yet. Just wondering if this is the right approach based on the deploy
issue above?
When using Vagrant, in our case ansible-bedrock, how to get db pull to work? Shouldnt the db dump download to the vagrant host? And from that place be executed?
Or is it designed to run the cap files within the vagrant machine?
Please, some examples would be worth gold :-)
I just setup capistrano-wpcli to push from local to stage.
Staging.rb
set :stage, :staging
server 'project.labs.domain.com', user: 'deploy', roles: %w{web app db}
fetch(:default_env).merge!(wp_env: :staging)
set :wpcli_remote_url, 'http://project.labs.domain.com/'
set :wpcli_local_url, 'http://project.dev/'
set :wpcli_args, 'staging'
When I push to stage I get no error messages
INFO[7386ee4b] Running /usr/bin/env wp db export - | gzip > /tmp/wpcli_database.sql.gz on localhost
INFO[7386ee4b] Finished in 0.008 seconds with exit status 0 (successful).
INFOUploading /tmp/wpcli_database.sql.gz 100.0%
INFO[4aad959f] Running /usr/bin/env gunzip < /tmp/wpcli_database.sql.gz | wp db import - on project.labs.domain.com
INFO[4aad959f] Finished in 0.153 seconds with exit status 0 (successful).
INFO[20c0aa98] Running /usr/bin/env rm /tmp/wpcli_database.sql.gz on project.labs.domain.com
INFO[20c0aa98] Finished in 0.056 seconds with exit status 0 (successful).
INFO[ba98b0a6] Running /usr/bin/env wp search-replace http://project.dev/ http://project.labs.domain.com/ staging on project.labs.domain.com
INFO[ba98b0a6] Finished in 0.785 seconds with exit status 0 (successful).
INFO[7b41a576] Running /usr/bin/env rm /tmp/wpcli_database.sql.gz on localhost
INFO[7b41a576] Finished in 0.006 seconds with exit status 0 (successful).
But if I check the staging site I cannot see any changes? The pages + settings on my local environment does not appear on the stage . What exactly should get pushed?
Could you please provide an example on how to set up the upload settings, what sort of path should be provided?
Would be great if you could update this gem to capistrano 3.6
There are tons of usefull features that came with 3.5
Ok, I have spent long enough on this issue where I figured on posting it.
When running a cap staging wpcli:db:pull I keep getting hung here.
$ cap staging wpcli:db:pull --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke wpcli:db:pull (first_time)
** Execute wpcli:db:pull
00:00 wpcli:db:pull
01 wp db export - | gzip > /tmp/wpcli_database.sql.gz
✔ 01 mas_sf_serverpilot 0.563s
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 10.17%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 20.35%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 30.52%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 40.69%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 50.87%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 61.04%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 71.21%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 81.39%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 90.11%
Downloading C:/xampp/htdocs/tmp/wpcli_database.sql.gz 100.0%
02 rm /tmp/wpcli_database.sql.gz
✔ 02 mas_sf_serverpilot 0.108s
03 gunzip -c C:/xampp/htdocs/tmp/wpcli_database.sql.gz > C:/xampp/htdocs/tmp/wpcli_database.sql
03 'export' is not recognized as an internal or external command,
03 operable program or batch file.
cap aborted!
SSHKit::Command::Failed: gunzip exit status: 256
gunzip stdout: Nothing written
gunzip stderr: 'export' is not recognized as an internal or external command,
operable program or batch file.
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/command.rb:99:in exit_status=' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/local.rb:59:in
block in execute_command'
C:/Ruby24-x64/lib/ruby/2.4.0/open3.rb:205:in popen_run' C:/Ruby24-x64/lib/ruby/2.4.0/open3.rb:95:in
popen3'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/local.rb:44:in execute_command' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/abstract.rb:145:in
block in create_command_and_execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/abstract.rb:145:in tap' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/abstract.rb:145:in
create_command_and_execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/abstract.rb:78:in execute' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/capistrano-wpcli-0.1.4/lib/capistrano/tasks/wpdb.rake:67:in
block (4 levels) in <top (required)>'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/abstract.rb:29:in instance_exec' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sshkit-1.18.0/lib/sshkit/backends/abstract.rb:29:in
run'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/capistrano-3.11.0/lib/capistrano/dsl.rb:76:in run_locally' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/capistrano-wpcli-0.1.4/lib/capistrano/tasks/wpdb.rake:65:in
block (3 levels) in <top (required)>'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/task.rb:273:in block in execute' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/task.rb:273:in
each'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/task.rb:273:in execute' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/airbrussh-1.3.1/lib/airbrussh/rake/context.rb:62:in
execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/task.rb:214:in block in invoke_with_call_chain' C:/Ruby24-x64/lib/ruby/2.4.0/monitor.rb:214:in
mon_synchronize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/task.rb:194:in invoke_with_call_chain' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/task.rb:183:in
invoke'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:160:in invoke_task' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:116:in
block (2 levels) in top_level'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:116:in each' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:116:in
block in top_level'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:125:in run_with_threads' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:110:in
top_level'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:83:in block in run' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:186:in
standard_exception_handling'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.3.2/lib/rake/application.rb:80:in run' C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/capistrano-3.11.0/lib/capistrano/application.rb:14:in
run'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/capistrano-3.11.0/bin/cap:3:in <top (required)>' C:/Ruby24-x64/bin/cap:23:in
load'
C:/Ruby24-x64/bin/cap:23:in `
I'm on a windows 10 OS, but using GITbash. Any ideas?
Hey there, just providing some bulk feedback in here:
remote_tmp_dir
just duplicates Capistrano's built in tmp_dir
var. If you wanted to keep the name you should just do:set :remote_tmp_dir, fetch(:tmp_dir)
WP_REMOTE_URL
and WP_HOME
should be named consistently (WP_HOME_URL
).application
is already a built in Capistrano var too. See https://github.com/roots/bedrock/blob/master/config/deploy.rb#L1.wpcli
. Example: remote_db_file
=> wpcli_remote_db_file
.with path: "#{fetch(:path)}:$PATH"
as someone can use the SSHKit command mapping to specify where wp
is on their remote system. Global path setting can also be done with:set :default_env, { path: "/opt/ruby/bin:$PATH" }
Hope this makes sense and helps.
Backing up remote database works fine but if i try to push database I am getting the following error:
bash: -c: line 1: syntax error: unexpected end of file
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: wp exit status: 1
wp stdout: Nothing written
wp stderr: bash: -c: line 1: syntax error: unexpected end of file
SSHKit::Command::Failed: wp exit status: 1
wp stdout: Nothing written
wp stderr: bash: -c: line 1: syntax error: unexpected end of file
Tasks: TOP => wpcli:db:push
Any idea?
Some of my clients use shared hosting (Godaddy), so I'm not able to install the bin/
executable, unfortunately. Is there a option I can use to execute a local ./wp-cli.phar
file instead? If not, would you be interested in a pull request?
Im not sure how to get started with this. I did the gem install. What else is needed to get this going?
Hey, thanks for this gem! I just have a little issue which I think can be easily fixed.
The :uploads:rsync:push
task times out if the server requires a non-standard port or key setting.
I know I can set wpcli_rsync_options manually to change the port and/or keyfile settings, but those will already be defined in the stage's ssh_options, so it doesn't seem right to start adding configs that are already defined. Plus, I'm not that good with the Capistrano syntax so I'm hoping someone else will see this issue and deal with it better than me.
Ideally, I guess the task would check for the following settings in the current stage and join it to them with the appropriate flags in the rsync options array.
set :ssh_options, {
keys: %w(/home/user/.ssh/deploy_key),
port: 4444
}
Right?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.