welaika / wordmove

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

Local mysqldump : Return code reports an error (Wordmove::ShellCommandError) #246

Closed taliesinpenbardd closed 8 years ago

taliesinpenbardd commented 8 years ago

Hey all,

I've read a lot about mysqldump errors and while some issues were rather similar to mine, I did not find a satisfying solution. As I'm quite new to wordmove, sorry if I ask silly questions.

I'm on Mac OS 10.11.1 ; I have MAMP installed (but not running), plus - obviously - VVV, vv and wordmove. I'm all good until pushing/pulling.

Although the one with a problem, the database push/pull throws back an error :

▬▬ ✓ Pushing Database ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
mysqldump --host=myhost.com --user=username --password=password tablename --result-file=/homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql
   remote | mysqldump --host=myhost.com --user=username --password=password tablename --result-file=/homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql
   remote | get: /homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql /Users/username/Local/www/sitename/htdocs/wp-content/staging-backup-1448565861.sql
   remote | delete: /homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql
mysqldump --host=127.0.0.1 --user=root --password=root sitename --result-file=/Users/username/Local/www/sitename/htdocs/wp-content/dump.sql
    local | mysqldump --host=127.0.0.1 --user=root --password=root sitename --result-file=/Users/username/Local/www/sitename/htdocs/wp-content/dump.sql
/Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/deployer/base.rb:136:in `run': Return code reports an error (Wordmove::ShellCommandError)
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/deployer/base.rb:208:in `save_local_db'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:17:in `push_db'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:60:in `block in push'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:36:in `block in handle_options'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:34:in `each'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:34:in `handle_options'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:59:in `push'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/exe/wordmove:6:in `<top (required)>'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/wordmove:23:in `load'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/wordmove:23:in `<main>'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

Following advices from there, I sshed Vagrant and passed the local mysqldump, the one causing problem :

vagrant@vvv:~$ mysqldump --host=127.0.0.1 --user=root --password=root tablename --result-file=/Users/username/Local/www/sitename/htdocs/wp-content/dump.sql
mysqldump: Can't create/write to file '/Users/username/Local/www/sitename/htdocs/wp-content/dump.sql' (Errcode: 2)

I did chmod -R 755 htdocs/ but that doesn't change anything.

Any idea on how to solve this ? Now that I know it could work, that's frustrating to be stopped here...

Thanks by advance.

taliesinpenbardd commented 8 years ago

Still no luck. Did try again, changing the absolute path from

/Users/username/Local/www/sitename/htdocs

to

/srv/www/sitename/htdocs

Seemed to make sens, since the vagrant session lives inside the virtualbox. Got a different error, though :

▬▬ ✓ Pushing Database ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
mysqldump --host=mysite.com --user=username --password=password dbname --result-file=/homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql
   remote | mysqldump --host=mysite.com --user=username --password=password dbname --result-file=/homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql
   remote | get: /homepages/27/username/htdocs/tests/sitename/wp-content/dump.sql /srv/www/sitename/htdocs/wp-content/staging-backup-1448642393.sql
/Users/username/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp/download.rb:156:in `initialize': No such file or directory @ rb_sysopen - /srv/www/sitename/htdocs/wp-content/staging-backup-1448642393.sql (Errno::ENOENT)
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp/download.rb:156:in `new'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp/download.rb:156:in `read_file'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp/download.rb:51:in `read_directive_state'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp.rb:369:in `block (3 levels) in start_command'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/channel.rb:311:in `call'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/channel.rb:311:in `process'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:223:in `block in preprocess'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:223:in `each'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:223:in `preprocess'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:206:in `process'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:170:in `block in loop'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:170:in `loop'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/session.rb:170:in `loop'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.3.beta1/lib/net/ssh/connection/channel.rb:269:in `wait'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp.rb:321:in `download!'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/photocopier-1.0.0/lib/photocopier/ssh.rb:17:in `get'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:42:in `block (2 levels) in <class:SSH>'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:60:in `download_remote_db'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:15:in `push_db'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:60:in `block in push'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:36:in `block in handle_options'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:34:in `each'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:34:in `handle_options'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/lib/wordmove/cli.rb:59:in `push'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/username/.rvm/gems/ruby-2.1.2/gems/wordmove-1.3.1/exe/wordmove:6:in `<top (required)>'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/wordmove:23:in `load'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/wordmove:23:in `<main>'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/username/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

Any idea on what info I could give to help finding the answer ?

taliesinpenbardd commented 8 years ago

Why does it come that the absolute Mac OS path for a local install works for everything but the database pull/push, and that the absolute path from the Vagrant server works for db push/pull and not for the other push/pulls ?

vagrant@vvv:~$ mysqldump --host=127.0.0.1 --user=root --password=root tablename --result-file=/Users/username/Local/www/sitename/htdocs/wp-content/local-backup-1448805242.sql
mysqldump: Can't create/write to file '/Users/username/Local/www/sitename/htdocs/wp-content/local-backup-1448805242.sql' (Errcode: 2)
vagrant@vvv:~$ mysqldump --host=127.0.0.1 --user=root --password=root tablename --result-file=/srv/www/sitename/htdocs/wp-content/local-backup-1448805242.sql

In the latter, the file is well created and weights 558 ko...

Anyone can help, please ? Need more info ?

kevinwhoffman commented 8 years ago

Let's focus on getting things working within VVV, because your paths will be different based on whether you are using Wordmove via SSH within VVV or in the host machine with MAMP.

If calling Wordmove via SSH within VVV, your local settings should look something like this:

local:
  vhost: "http://sitename.dev"
  wordpress_path: "/srv/www/sitename/htdocs/" # use an absolute path here

  database:
    name: "sitename"
    user: "root"
    password: "root"
    host: "127.0.0.1"

If you need additional help, please post a screenshot of your directory structure and a copy of your Movefile without credentials.

taliesinpenbardd commented 8 years ago

Thanks for your help.

So, we work within VVV. Here is my movefile (without credentials) :

local:
  vhost: "http://mediassoc.dev"
  wordpress_path: "/srv/www/mediassoc/htdocs" # use an absolute path here

  database:
    name: "mediassoc"
    user: "root"
    password: "root"
    host: "127.0.0.1"

production: # multiple environments can be specified
  vhost: "http://mediassoc.org"
  wordpress_path: "/var/www/vhosts/mediassoc.org/httpdocs/wp" # use an absolute path here

  database:
    name: "mediassoc"
    user: "username"
    password: "password"
    host: "localhost"
    # port: "3308" # Use just in case you have exotic server config

  exclude:
    - ".git/"
    - ".gitignore"
    - ".sass-cache/"
    - "node_modules/"
    - "bin/"
    - "tmp/*"
    - "Gemfile*"
    - "Movefile"
    - "wp-config.php"
    - "wp-content/*.sql"
    - "DS_Store"

  # 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/languages"
  #   themes: "wp-content/themes"

  ssh:
    host: "hostaddress"
    user: "username"
    password: "password" # password is optional, will use public keys if available.
    # port: 22 # Port is optional
    rsync_options: "--verbose" # Additional rsync options, optional

(No staging for now, as I have a side problem about my own server, but that'll come later).

Directory structure is : directory-structure I'm still having an error, at the same moment :

▬▬ ✓ Pulling Database ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
mysqldump --host=127.0.0.1 --user=root --password=root mediassoc --result-file=/srv/www/mediassoc/htdocs/wp-content/local-backup-1449060466.sql
    local | mysqldump --host=127.0.0.1 --user=root --password=root mediassoc --result-file=/srv/www/mediassoc/htdocs/wp-content/local-backup-1449060466.sql
mysqldump --host=localhost --user=username --password=password mediassoc --result-file=/var/www/vhosts/mediassoc.org/httpdocs/wp/wp-content/dump.sql
   remote | mysqldump --host=localhost --user=username --password=password mediassoc --result-file=/var/www/vhosts/mediassoc.org/httpdocs/wp/wp-content/dump.sql
/usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:51:in `remote_run': Error code 2 returned by command "mysqldump --host=localhost --user=username --password=password mediassoc --result-file=/var/www/vhosts/mediassoc.org/httpdocs/wp/wp-content/dump.sql": mysqldump: Got error: 1045: Access denied for user 'username'@'localhost' (using password: YES) when trying to connect (Wordmove::ShellCommandError)
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:58:in `download_remote_db'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/deployer/ssh.rb:30:in `pull_db'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/cli.rb:49:in `block in pull'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/cli.rb:36:in `block in handle_options'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/cli.rb:34:in `each'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/cli.rb:34:in `handle_options'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/lib/wordmove/cli.rb:48:in `pull'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
  from /usr/local/rvm/gems/ruby-2.2.1/gems/wordmove-1.3.1/exe/wordmove:6:in `<top (required)>'
  from /usr/local/rvm/gems/ruby-2.2.1/bin/wordmove:23:in `load'
  from /usr/local/rvm/gems/ruby-2.2.1/bin/wordmove:23:in `<main>'
  from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
  from /usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

Any idea on what I'm doing wrong ? Thanks by advance.

taliesinpenbardd commented 8 years ago

And it works ! Thanks for forcing me to start from the very beginning.

The thing is, I was trying to make wordmove work from outside the Vagrant session. I've recreated my Movefile from within Vagrant (and install sshpass) and it works.

Cheers !

kevinwhoffman commented 8 years ago

Glad you got it figured :)