HandiworkNYC.com
HandiworkNYC.com

Reputation: 11124

Using Grunt and rsync to sync remote folder with a local folder

I've successfully installed Grunt Rsync https://github.com/jedrichards/grunt-rsync and had success 'syncing' a local folder to a remote folder.

rsync: {
    options: {
        args: ["--verbose"],
        recursive: true
    },
    stage: {
        options: {
            src: "/Applications/MAMP/htdocs/barestrap-wp/library/uploads",
            dest: "shared/library/uploads",
            host: "[email protected]",
            syncDestIgnoreExcl: true
        }
    }
},

The success response in terminal is:

Shell command was: rsync /Applications/MAMP/htdocs/barestrap-wp/library/uploads [email protected]:shared/library --rsh ssh --recursive --delete --verbose

My "problem" is that this overwrites the "uploads" folder in the SSH host completely, i.e. [email protected]:shared/library/uploads gets deleted. I'm not sure how to remove --delete from the options.

What I'm trying to do is 1) make sure that the SSH uploads folder contains all the files from the local environment, and 2) that the local environment contains all the files from the remote SSH environment.

This grunt task is partially successful in the first goal, but I'm unsure of how to achieve the second– in other words:

$ rsync [email protected]:shared/library /Applications/MAMP/htdocs/barestrap-wp/library/uploads

Any insights are very much appreciated.

Thank you!

Upvotes: 1

Views: 1391

Answers (1)

K. Alan Bates
K. Alan Bates

Reputation: 3164

Your culprit is the syncDestIgnoreExcl: true setting in your options. From the conversation had in Issue #32 reported to grunt-rsync, that setting needs to be false to keep your destination folder from purging files that do not exist in your source directory.

Upvotes: 1

Related Questions