Deploying WordPress via Rsync with Grunt

In this article, I'd like to show you a quick implementation of grunt-rsync working in conjunction with a Gulp build.

In the previous article about WordPress deployments via Gulp, I wrote about Gulp’s shortcomings with respect to pushing codebases up to servers. In this article, I’d like to show you a quick implementation of grunt-rsync working in conjunction with a Gulp build.

At this point, you’re able to type “gulp build” and have a clean, compressed build of your WordPress installation in a /runtime/ folder. Now we’re going to make it so that you can type “grunt deploy” or “grunt stage” to upload that installation in one chunk to your server.

The Gruntfile is relatively straightforward:

A few things to note:

  • I’m using grunt-rsync-2 because grunt-rsync would not work for me.
  • You need to set up an SSH user on your server (in this example “rsync_user“) that can log in automatically from your machine without entering a password. There are many articles out there about how to do this, but basically you need to be able to type ssh rsync_user@mywebsite.com into the command line and get into the server without a password prompt.
  • The remote_dev and remote_stage addresses will vary depending on your server setup, and what root folder you let your rsync_user log into initially. For example, if your rsync_user FTPs into ~/home/ by default, and you keep your WordPress install in ~/home/my-wordpress/ then you want to put ~/home/my-wordpress/ as the remote path.

Photo by Elian Chrebor.

Deploying WordPress

Build Scripts for WordPress

Post a Comment

Your Two Cents


Your Comments

4 Replies & Counting

  1. Deryck 4 years, 5 months ago

    Hello Elian, grate article. Very simple and useful. I´m starting with rsync using grunt and after follow your post I found and issue. I get:

    bash: rsync: command not found
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: remote command not found (code 127) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]

    Do you know the cause? I´m using Mac OS X.

    Thanks in advance.

    • Daniel Quinn 4 years, 5 months ago

      I think it may be that you don’t have rsync installed on your server.

  2. Jon 4 years, 2 months ago

    So you would use gulp for the whole development and grunt for uploading, is that right?

    Is it possible to set up a localhost to work with gulp or grunt, to work locally with dynamic files such as php from wordpress?

    I am still debating whether going for grunt or gulp. Everybody seems to be migrating to gulp these days.


    • Daniel Quinn 4 years, 1 month ago

      – Yes, in this example you are using gulp to build and grunt to deploy.

      – Yes, it works locally.

      I would have gone 100% gulp if it weren’t that gulp’s deploy options weren’t as robust’s as grunt’s. Until then…