<p>I use <code>rsync</code> with <a href="http://gruntjs.com/">grunt</a>. There is a <a href="https://github.com/jedrichards/grunt-rsync">grunt rsync task</a>, which is just a wrapper for raw rsync. If all I used grunt for was the rsync I don't think it would be worth it, but I use it to compile my sass, and to reload my browser (<a href="https://github.com/gruntjs/grunt-contrib-sass">grunt-contrib-sass</a>, <a href="https://github.com/gruntjs/grunt-contrib-watch">grunt-contrib-watch</a>) among other things.</p>

CC BY-SA 3.0
2014-07-27T11:16:13.797Z
Fantastic. This is really helpful. Thanks!
Matt Stauffer
CC BY-SA 3.0
2014-07-27T16:45:07.837Z
I think of rsync as a really sharp knife - super useful, but it will cut...
Marion Newlevant
CC BY-SA 3.0
2014-07-27T05:18:31.613Z
2014-07-27T05:18:31.613Z
Marion Newlevant
<p>Another alternative to grunt is to use <a href="http://gulpjs.com/">http://gulpjs.com/</a>. This is what I use for minifying css js and assets etc. I've been meaning to setup a way of syncing folders so I've put together gulp task to do it. I have roughly tested it but you might want to look over the code before you use it on a production site :) Be aware that it is setup to sync the folder so it will remove any local files that are not present on your staging/production server.</p>

<p>To use gulp you need to have node.js installed with npm. First install gulp globally:</p>

<pre><code>npm install -g gulp
</code></pre>

<p>you might need to run that as sudo.</p>

<p>Next, in the root of your craft project create a gulpfile.js that looks something like this:</p>

<pre><code>// Gulp
var gulp = require('gulp');

// Plugins
var rsync = require("rsyncwrapper").rsync;

// Pull down assets and sync local folder
gulp.task('synclocal', function(){
    rsync({
        src: "username@hostname.com:/path/to/assets",
        dest: "assets",
        ssh: true,
        recursive: true,
        syncDest: true,
        compareMode: "checksum"
    },function (error,stdout,stderr,cmd) {
        if ( error ) {
            // failed
            console.log(error.message);
        } else {
            // success
            console.log("folder synced!")
        }
    });
});
</code></pre>

<p>Finally we need to make sure rsyncwrapper is install. You can do this by running:</p>

<pre><code>npm install rsyncwrapper
</code></pre>

<p>You should now be able to run the task by typing:</p>

<pre><code>gulp synclocal
</code></pre>

CC BY-SA 3.0
2014-07-27T11:15:39.353Z
Brilliant! Great idea!
Matt Stauffer
CC BY-SA 3.0
2014-07-27T06:30:49.643Z
2014-07-27T06:30:49.643Z
Dave Coggins
<p>I think this might be the plugin you are looking for: </p>

<p><a href="https://github.com/boboldehampsink/zipassets" rel="nofollow">https://github.com/boboldehampsink/zipassets</a></p>

<p>It allows you to download a zip of selected assets, might be easy to specify all assets within the plugin.</p>

CC BY-SA 3.0
2014-07-26T01:44:31.917Z
Hm, maybe hooking that up to a "get all asset IDs" request and then making it a control panel button might be the ticket--thanks! I'll take a look further into it.
Matt Stauffer
CC BY-SA 3.0
2014-07-26T01:46:22.977Z
Would love to see what you end up doing! You are referring to local assets and not S3 correct?
Jason McCallister
CC BY-SA 3.0
2014-07-26T01:46:51.030Z
Yep, just for local assets at the moment.
Matt Stauffer
CC BY-SA 3.0
2014-07-26T01:34:44.347Z
2014-07-26T01:34:44.347Z
Jason McCallister
<p>You might want to take a look at capistrano if your looking at ways to automate sync mutliple environments:</p>

<p><a href="http://capistranorb.com/" rel="nofollow">http://capistranorb.com/</a></p>

<p>Not sure what your local environment is like but if you have ruby installed, capistrano might be be something to consider for automation. There are plenty examples across the web of how to use it to sync databases and folders. It used to be heavily tied to rails app but as of recent versions I believe it is more agnostic. I know I'll be looking into this in the coming weeks once I get some spare time.</p>

CC BY-SA 3.0
2014-07-27T00:44:06.280Z
Thanks Dave! I've been itching to learn Capistrano for a while. I'd prefer an option that doesn't require Ruby so we had a community wide standard method, but this is definitely a route to go for more complex needs. Thanks!!
Matt Stauffer
CC BY-SA 3.0
2014-07-27T02:49:43.553Z
Hi Matt, if you'd prefer php take a look at http://deployer.in/ I haven't tried it myself but it looks promising. I'm sure there is another one I stumbled across a while ago but I can't seem to find it. I'll let you know if I do though.
Dave Coggins
CC BY-SA 3.0
2014-07-26T06:15:52.417Z
2014-07-26T06:15:52.417Z
Dave Coggins
<p>Just updating this thread with another option. Also using Rsync but through the Mac app Dropsync3 <a href="http://mudflatsoftware.com/" rel="nofollow">http://mudflatsoftware.com/</a></p>

<p>Pretty cool, I'm currently getting the "dump" plugin to make a daily db backup via Cron and then getting Dropsync to sync the "storage" folder with a folder on my computer (that is version controlled).</p>

<p>Also doing similarly with assets and just debating the best way to handle system updates.</p>

CC BY-SA 3.0
2016-05-03T10:08:26.397Z
2016-05-03T10:08:26.397Z
André Goldstein
<p>In case it's of use to anyone coming to this thread, I maintain a project called <a href="https://github.com/niceandserious/crafty-vagrant" rel="nofollow">Crafty Vagrant</a>, which is intended to be a handy dev environment / boilerplate starting point for Craft projects, and which has (among other things) both asset-syncing, in the form of a Gulp task (eg. <code>gulp rsync:fromstage</code>), and simplified database provisioning (<code>vagrant provision --provision-with shell</code> drops the current local database and replaces it with the most recent backup from Craft's backups directory).</p>

CC BY-SA 3.0
2016-05-13T13:44:11.417Z
2016-05-13T13:44:11.417Z
Nick F
<p>I made a simple script to do this. It's much, much less powerful than Capistrano, but with a few tweaks I think it'll be more flexible (for starters, not requiring Ruby or learning Cap).</p>

<p><a href="https://github.com/mattstauffer/syncCraft" rel="nofollow">https://github.com/mattstauffer/syncCraft</a></p>

<p><strong>My Original solution, pre-syncCraft:</strong></p>

<p>FYI, this is what I'm doing right now. It's not good enough, but I'll put it up for reference... I run this from the command line:</p>

<pre><code>scp myuser@myhost:/path/to/site/public/assets/images/content/* /local/path/to/site/public/assets/images/content/
</code></pre>

<p>But it's manual, and not smart enough to avoid overwriting stuff locally. I think I could use <code>rsync</code> to avoid overwriting locally, but again, I feel like a Craft plugin might(?) be a better option.</p>

<p>Here's the <code>rsync</code> version:</p>

<pre><code>rsync -auv myuser@myhost:/path/to/site/public/assets/images/content/* /local/path/to/site/public/assets/images/content/
</code></pre>

CC BY-SA 3.0
2014-07-26T01:47:40.340Z
Probably depends on how many Assets you'll be pulling down.  If it's gigs and gigs, you'll bump into memory and execution time limits with PHP.  Something like rsync (even if triggered from PHP), might be more reliable then.
Brad Bell
CC BY-SA 3.0
2014-07-26T01:49:07.977Z
Ahhh--ok, good thought. I'll probably try an rsync-based version, and just do my best to make it as simple to install as possible (trying to get the workflow so simple that it's not a huge pain to add to a new site).
Matt Stauffer
CC BY-SA 3.0
2014-07-26T01:58:55.723Z
OK, rsync version is a ton better, but it's still super manual to add it. Might have to make something happen.
Matt Stauffer
CC BY-SA 3.0
2014-07-26T02:00:12.660Z
If you've got a script that handles the other stuff (pulling db down, nuking local, reinstalling), why not have the script trigger rsync?
Brad Bell
CC BY-SA 3.0
2014-07-26T02:01:38.117Z
I don't. I do the rest manually now. But I think this is my motivation to throw it all into a script. There wouldn't be an easy method I could run from my shell script to trigger a backup, would there? :hopeful: :)
Matt Stauffer
CC BY-SA 3.0
2014-07-26T02:03:54.880Z
From a shell script?  Probably mysqldump (https://dev.mysql.com/doc/refman/5.1/en/backup-methods.html). If it were a plugin you could use craft()->db->backup().
Brad Bell
CC BY-SA 3.0
2014-07-26T01:43:47.450Z
2014-07-27T17:18:32.960Z
2014-07-27T17:18:32.960Z
Matt Stauffer
<p>I'm trying to speed up the process of synchronizing my production site down to my local install. Currently, it is: Back up database, wipe local database, import database backup. It's not perfect, but it is pretty fast.</p>

<p>But synchronizing the assets down is still a pain. Is there a process or plugin that makes it easy/easier to synchronize assets (uploaded photos, etc.) between installs?</p>

<assets>
Is there an easy way to download the assets directory to a local install?
# Is there an easy way to download the assets directory to a local install?

(Asked by: username_0 on 2014-07-26)

I'm trying to speed up the process of synchronizing my production site down to my local install. Currently, it is: Back up database, wipe local database, import database backup. It's not perfect, but it is pretty fast.

But synchronizing the assets down is still a pain. Is there a process or plugin that makes it easy/easier to synchronize assets (uploaded photos, etc.) between installs?

**Tags:** assets


---

## 7 answers

### Answer by username_0 on 2014-07-26. Score: 7 | Accepted answer

I made a simple script to do this. It's much, much less powerful than Capistrano, but with a few tweaks I think it'll be more flexible (for starters, not requiring Ruby or learning Cap).
https://github.com/mattstauffer/syncCraft
My Original solution, pre-syncCraft:
FYI, this is what I'm doing right now. It's not good enough, but I'll put it up for reference... I run this from the command line:
scp myuser@myhost:/path/to/site/public/assets/images/content/* /local/path/to/site/public/assets/images/content/

But it's manual, and not smart enough to avoid overwriting stuff locally. I think I could use rsync to avoid overwriting locally, but again, I feel like a Craft plugin might(?) be a better option.
Here's the rsync version:
rsync -auv myuser@myhost:/path/to/site/public/assets/images/content/* /local/path/to/site/public/assets/images/content/

> **Comments:**
> **username_6**: Probably depends on how many Assets you'll be pulling down.  If it's gigs and gigs, you'll bump into memory and execution time limits with PHP.  Something like rsync (even if triggered from PHP), might be more reliable then.  
> **username_0**: Ahhh--ok, good thought. I'll probably try an rsync-based version, and just do my best to make it as simple to install as possible (trying to get the workflow so simple that it's not a huge pain to add to a new site).  
> **username_0**: OK, rsync version is a ton better, but it's still super manual to add it. Might have to make something happen.  
> **username_6**: If you've got a script that handles the other stuff (pulling db down, nuking local, reinstalling), why not have the script trigger rsync?  
> **username_0**: I don't. I do the rest manually now. But I think this is my motivation to throw it all into a script. There wouldn't be an easy method I could run from my shell script to trigger a backup, would there? :hopeful: :)  
> **username_6**: From a shell script?  Probably mysqldump (https://dev.mysql.com/doc/refman/5.1/en/backup-methods.html). If it were a plugin you could use craft()->db->backup().  

---

### Answer by username_1 on 2014-07-27. Score: 8

I use `rsync` with [grunt](http://gruntjs.com/). There is a [grunt rsync task](https://github.com/jedrichards/grunt-rsync), which is just a wrapper for raw rsync. If all I used grunt for was the rsync I don't think it would be worth it, but I use it to compile my sass, and to reload my browser ([grunt-contrib-sass](https://github.com/gruntjs/grunt-contrib-sass), [grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch)) among other things.

> **Comments:**
> **username_0**: Fantastic. This is really helpful. Thanks!  
> **username_1**: I think of rsync as a really sharp knife - super useful, but it will cut...  

---

### Answer by username_2 on 2014-07-27. Score: 7

Another alternative to grunt is to use http://gulpjs.com/. This is what I use for minifying css js and assets etc. I've been meaning to setup a way of syncing folders so I've put together gulp task to do it. I have roughly tested it but you might want to look over the code before you use it on a production site :) Be aware that it is setup to sync the folder so it will remove any local files that are not present on your staging/production server.
To use gulp you need to have node.js installed with npm. First install gulp globally:
npm install -g gulp

you might need to run that as sudo.
Next, in the root of your craft project create a gulpfile.js that looks something like this:
// Gulp
var gulp = require('gulp');

// Plugins
var rsync = require("rsyncwrapper").rsync;

// Pull down assets and sync local folder
gulp.task('synclocal', function(){
    rsync({
        src: "username@hostname.com:/path/to/assets",
        dest: "assets",
        ssh: true,
        recursive: true,
        syncDest: true,
        compareMode: "checksum"
    },function (error,stdout,stderr,cmd) {
        if ( error ) {
            // failed
            console.log(error.message);
        } else {
            // success
            console.log("folder synced!")
        }
    });
});

Finally we need to make sure rsyncwrapper is install. You can do this by running:
npm install rsyncwrapper

You should now be able to run the task by typing:
gulp synclocal

> **Comments:**
> **username_0**: Brilliant! Great idea!  

---

### Answer by username_3 on 2014-07-26. Score: 4

I think this might be the plugin you are looking for:

<https://github.com/boboldehampsink/zipassets>

It allows you to download a zip of selected assets, might be easy to specify all assets within the plugin.

> **Comments:**
> **username_0**: Hm, maybe hooking that up to a "get all asset IDs" request and then making it a control panel button might be the ticket--thanks! I'll take a look further into it.  
> **username_3**: Would love to see what you end up doing! You are referring to local assets and not S3 correct?  
> **username_0**: Yep, just for local assets at the moment.  

---

### Answer by username_2 on 2014-07-26. Score: 4

You might want to take a look at capistrano if your looking at ways to automate sync mutliple environments:

<http://capistranorb.com/>

Not sure what your local environment is like but if you have ruby installed, capistrano might be be something to consider for automation. There are plenty examples across the web of how to use it to sync databases and folders. It used to be heavily tied to rails app but as of recent versions I believe it is more agnostic. I know I'll be looking into this in the coming weeks once I get some spare time.

> **Comments:**
> **username_0**: Thanks Dave! I've been itching to learn Capistrano for a while. I'd prefer an option that doesn't require Ruby so we had a community wide standard method, but this is definitely a route to go for more complex needs. Thanks!!  
> **username_2**: Hi Matt, if you'd prefer php take a look at http://deployer.in/ I haven't tried it myself but it looks promising. I'm sure there is another one I stumbled across a while ago but I can't seem to find it. I'll let you know if I do though.  

---

### Answer by username_4 on 2016-05-03. Score: 3

Just updating this thread with another option. Also using Rsync but through the Mac app Dropsync3 <http://mudflatsoftware.com/>

Pretty cool, I'm currently getting the "dump" plugin to make a daily db backup via Cron and then getting Dropsync to sync the "storage" folder with a folder on my computer (that is version controlled).

Also doing similarly with assets and just debating the best way to handle system updates.


---

### Answer by username_5 on 2016-05-13. Score: 1

In case it's of use to anyone coming to this thread, I maintain a project called [Crafty Vagrant](https://github.com/niceandserious/crafty-vagrant), which is intended to be a handy dev environment / boilerplate starting point for Craft projects, and which has (among other things) both asset-syncing, in the form of a Gulp task (eg. `gulp rsync:fromstage`), and simplified database provisioning (`vagrant provision --provision-with shell` drops the current local database and replaces it with the most recent backup from Craft's backups directory).


---

