webrain / grunt-wordpress-deploy Goto Github PK
View Code? Open in Web Editor NEWA Grunt plugin to quickly deploy Wordpress websites.
License: MIT License
A Grunt plugin to quickly deploy Wordpress websites.
License: MIT License
Can't get past this error. The syntax in the gruntfile is correct. Do I need to install rsync locally?
I'd like to be able to type "grunt deploy" and have it run my default grunt tasks (concat, minify, etc) then run push_db and push_files
Also would like the opposite when I type "grunt pull" or something similar.
Right now there's no way (that I've found) to register a task and still add the "target" parameter.
grunt pull_db --target="staging"
Pulling database from 'staging' into Local
>> Creating DUMP of remote database
Password:
>> Database DUMP succesfully exported to:
>> backups/staging/20150625/16-16-06/db_backup.sql
>> Adapt the database: set the correct urls for the destination in the database.
>> Creating DUMP of local database
>> Database DUMP succesfully exported to:
>> backups/local/20150625/16-16-06/db_backup.sql
>> Importing DUMP into local database
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bash: LW9@@T^x: command not found
Usage: mysqldump [OPTIONS] database [tables]
O' at line 1
>> Database imported succesfully
Operations completed
Done, without errors.
.sql file says:
bash: LW9@@T^x: command not found
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
Hey,
I am using MAMP Pro on Yosemite. I have moved the document root folder to Sites.
I am receiving the following error when running the task: grunt pull_db --target=staging
Anyone have any ideas on how to resolve this?
Thanks in advance.
Pulling database from 'staging' into Local
>> Creating DUMP of remote database
>> Database DUMP succesfully exported to:
>> backups/staging/20141205/21-29-25/db_backup.sql
>> Adapt the database: set the correct urls for the destination in the database.
>> Creating DUMP of local database
>> Database DUMP succesfully exported to:
>> backups/local/20141205/21-29-25/db_backup.sql
>> Importing DUMP into local database
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
>> Database imported succesfully
Operations completed
For some reasons, the pulled database dump contains the site_url option column without the http parameter, even if this was present into the Gruntfile configuration.
When I run the task I get the following error:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bash: -c: line 0: syntax error near unexpected token `)' bash: -c: line 0: `mysq' at line 1
Not sure if this is due to my system configuration or the plugin.
The error appears in the the staging .sql dumps but the grunt task says everything completes successfully. So it fails silently unless you add the flags --verbose --debug
when calling the command.
The local db dump file shows correct SQL information.
Could this be as simple as adding the ssh_host option for local environment?
Currently I'd have to manually ssh into vagrant, cd into theme directory where my gruntfile.js is located and run commands to push & pull database.
Some Wordpress plugins store escaped serialized data in the database. For example this escaped string http:\/\/example.com\/2013\/11\/image.jpg
is not replaced.
URLs of the local and the remote domain in database dumps are not changed (both directions)
Hey thanks for releasing this module! I've been looking around a bunch for a better WP deployment flow and this is really helpful.
It'd be great if you could also add a 'table_prefix' var that could dump only tables with that prefix. On my local machine (and sometimes on production, specifically with crappy shared hosts) I'll run a few wp installs and I only want to dump/pull down one of those. I'm new to grunt so I can try my hand at it and submit a PR if I get anywhere on it myself...
Awesome, this plugin comes in very handy. But tell me, how do you update the core WP code with this plugin?
I mean, do you download the core WP code from the site into the same directory and let the grunt task deploy the update to the site? Or do you generate/update it with Yeoman https://github.com/romainberger/yeoman-wordpress#configuration ?
Since this is clearly dead (no ERROR 1064 fix), can someone point me to an alternative?
I changed my ssh port for security reasons. Can i specify a custom port ?
This was a problem with grunt-deployments, so was probably not fixed at the time you forked that project.
In at least some versions of MySQL, if you put the DB password on the command line with the -p argument, the first line of the resulting .sql file will be:
"Warning: Using a password on the command line interface can be insecure."
When you then try to load this into another DB, it fails because of invalid SQ syntaxL.
A solution is to change the templates as follows:
mysqldump: "MYSQL_PWD=<%= pass %> mysqldump -h <%= host %> -u<%= user %> <%= database %>",
mysql: "MYSQL_PWD=<%= pass %> mysql -h <%= host %> -u <%= user %> <%= database %>",
Pardon me for asking, because this might be a stupid question, but:
Is there a way to target only a subsite (on a wordpress multisite install) with grunt-wordpress-deploy? We're working with 100+ live sites on the production environment and would like to prevent accidental overwrites.
Also it would be faster to just push and pull only the targeted subsite. Would love to hear from you, and thanks for a wonderful plugin!
The script seems to fail in the execution of mysql/mysqldump shell command execution if the password contains spaces.
The example gruntfile in the readme runs "wordpressdeploy" which results in:
Warning: Task "wordpressdeploy" not found. Use --force to continue.
I can run the built-in tasks like "grunt push_files --target=staging", but how should they be incorporated into the default task? Maybe a noob question :)
Thanks!
MAMP has mysqldump (http://stackoverflow.com/a/3269363) but for some reason, it says the command does not exist.
Allow the target to be specified as a task argument like "pull_db:prod", in addition to allowing it as an option or command-line argument (--target=).
Doing so allows multiple step tasks like:
grunt.registerTask('createtest', ['db_pull:prod", 'db_push:staging"]);
Sensible data, like database username and password, should be written in a different file than the Gruntfile. This way you can add to version control the Gruntfile without any privacy problem.
I've been trying to pull files from an environment to my local, and the files were not being added to the path that I've set in the local "path":
.
I've tried debugging it and figured out that if the target path is missing a trailing slash, it creates another folder in the local path directory, named after the target path's basename folder. Here's what I mean:
target path: "path": "/var/www/target_directory"
local path: "path": "/var/www/local_directory"
would add files in /var/www/local_directory/target_directory
Hope that makes sense. It wasn't mentioned in the docs, and the example is also missing the trailing slash.
With the WordPress 4.2, the new table collation is utf8mb4_unicode_ci. However that generates an error using grunt-wordpress-deploy:
ERROR 1273 (HY000) at line 25: Unknown collation: 'utf8mb4_unicode_ci'
I run the taks grunt push_db --target=staging
this is the result:
Pushing database from 'Local' to 'staging'
>> Creating DUMP of local database
>> Database DUMP succesfully exported to:
>> backups/local/20141210/02-58-28/db_backup.sql
>> Adapt the database: set the correct urls for the destination in the database.
>> Creating DUMP of remote database
>> Database DUMP succesfully exported to:
>> backups/staging/20141210/02-58-28/db_backup.sql
>> Importing DUMP into remote database
>> Database imported succesfully
Seems ok but when i enter the staging url the database is not updated. I thought the task upload the new db into my server.
am i wrong?
Hi,
I found Warning: Using a password on the command line interface can be insecure.
was appearing on line 1 of my staging sql dump file. This was causing SQL syntax error when trying to import locally.
I didn't use SSH host option to connect to the server not sure if this has something to do with the error message?
I found the same problem referenced here: http://stackoverflow.com/questions/20751352/suppress-warning-messages-using-mysql-from-within-terminal-but-password-written which suggests to use mysql_config_editor http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html.
As a temporary fix I removed the warning message by adding:
var preoutput = exports.replace_urls(old_url, new_url, content);
var output = exports.replace_urls("Warning: Using a password on the command line interface can be insecure.", " ", preoutput);
In util.js https://github.com/webrain/grunt-wordpress-deploy/blob/master/tasks/lib/util.js#L89
Am I authenticating wrong which is causing the warning to appear? Authenticating using the ssh_host option seemed to not allow the sqldump to generate due to -jailshell: FkX: command not found
errors appearing when trying to dump on the live server.
Thanks!
I have tried to push two different wordpress installations and both have had issues, either losing their widgets, random data or simply not working at all. I think it has something to do with the url replacement. If I leave my staging url identical to my local url and use http://github.com/interconnectit/search-replace-db after pushing the db, it works perfectly.
The difference I see is that "search-replace-db" uses the php @unserialize and then re-serializes which are both built in php functions. The "replace_urls_in_serialized" of course can't leverage these methods but there might be some issue with the regular expression being used.
running pull_db --target=staging returns:
mysqldump: Got error: 1045: "Access denied for user 'wpdeploy'@'ip.of.our.server' (using password: YES)" when trying to connect
staging: {
"title": "staging",
"database": "MWPdb",
"user": "wpdeploy",
"pass": "somepassword",
"host": "our.server.com",
"url": "http://our.server.com",
"path": "/opt/sites/www/wordpress",
"ssh_host": "[email protected]"
}
But when I run the command:
mysqldump -h our.server.com -u wpdeploy -p MWPdb
It just downloads the SQL. (ofc I entered the password first)
I've setup the task to use the same database username and password as in wp-config.php
but I keep encountering the same error 1045 in the SQL dump: "Access denied for user 'username'@'xxx.xxx.xxx.xx'
(using password: YES) when trying to connect"
I have my local and development environments setup. The files are successfully pushed to the development server and the local database is also pushed to the development server, but the values of the database are not changed (i.e. it doesn't seem like the search and replace nor the serializing data is happening on the database before it gets pushed to the development server). Any thoughts? I am posting my Gruntfile.js code below, but have changed some of the values for security purposes.
wordpressdeploy: {
options: {
backup_dir: "backups/",
rsync_args: ['--verbose', '--progress', '-rlpt', '--compress', '--omit-dir-times', '--delete'],
exclusions: ['Gruntfile.js', '.git/', 'tmp/*', 'backups/', 'wp-config.php', 'composer.json', 'composer.lock', 'README.md', '.gitignore', 'package.json', 'node_modules', '*.sublime-workspace', '*.sublime-project']
},
local: {
"title": "local",
"database": "snoringdoc",
"user": "root",
"pass": "root",
"host": "localhost",
"url": "http://localhost/Snoring-Doc/",
"path": "/Applications/MAMP/htdocs/Snoring-Doc/"
},
dev: {
"title": "dev",
"database": "dev_snoringdoc",
"user": "dev_admin",
"pass": "notactualpassword",
"host": "localhost",
"url": "http://snoringdoc.dev.com",
"path": "/home/dev/public_html/snoringdoc",
"ssh_host": "[email protected]"
}
},
Just thinking out loud: it might be nice if, instead of ignoring wp-config.php, this tool actually wrote to wp-config.php, updating it with the provided environment's database credentials and URLs (DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, WP_HOME) during a file deploy. Since all that information is already present in-the-clear in the Gruntfile.js, why not provide a way to provide that information to the config file during a deployment?
I'm getting the following error when trying to push DB to MariaDB on a production server.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '/bin/sh: mysqldump: command not found' at line 1
Does it work with MariaDB?
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.