Loading...
Tech / May 26 2016

Advanced ways to exclude files from sync

Ever wanted to exclude certain files from being synchronised in the cloud? Or the entire filetype? Here's how it can be done on Koofr.

Written by human for humans

Like many developers, we're always syncing a lot of our files into the cloud for backups. But sometimes, we don't want to have our builds or temporary files or some parts of repositories synced, because there's no point. There isn't a simple way of excluding files by name or type to be found in other clients. So we decided to implement it, and we took ideas from our beloved Git.

Is this for everyone to use?

Probably not. Its primary use will probably be for our fellow developers. But we can also imagine photographers wanting to only sync their exported JPGs without the large RAW file collection (or vice versa). You do need some basic skills in order to create the rules for exclusion or inclusion, but you can find a lot of examples with Google.

How does it work?

The trick is in a single file. To make use of our advanced exclusion (or inclusion) rules, you need to create a file called .syncignore in the root of the folder that is being synced (WARNING: the .syncignore file that is not at the root level of the synced folder, will be ignored!). If you have multiple synchronisations set-up, you will need a separate file in each of these root folders.

Important: It is smart to first create the .syncignore file inside the folder you wish to sync and then create the synchronisation to Koofr (if you do it on an already existing sync, the files will not be removed from the servers). Also, if you add the .syncignore file on an existing synchronisation, you must restart the sync client.

What to put in the .syncignore file?

Inside the .syncignore file, write the rules (one rule per line) by using the well known glob format.

Examples:

Ignore everything except .jpg files:

*
!*.jpg


Ignore development files (ie. node_modules) for your Node.js project:

Install Bower, Yeoman and webapp Yeoman generator:

npm install -g bower yo generator-webapp


Generate a sample webapp:

yo webapp


Add node_modules/ and bower_components/ to .syncignore file:

echo 'node_modules/' >> .syncignore
echo 'bower_components/' >> .syncignore


By default .syncignore file won't be synchronized. If you want to synchronize it (e.g. you are developing on more than one machine) you can include it manually:

echo '!.syncignore' >> .syncignore


Read more here.

Want to talk to us? Join us on the Koofr subreddit!