22

Using the Dropbox GUI, it's possible to controll specifically what folders to be synced. Can this somehow be done from the command-line too?

Background: I'm trying out the solutions for installing Dropbox on a linux server given here, and it seems to work fine: http://ubuntuservergui.com/ubuntu-server-guide/install-dropbox-ubuntu-server

Cambiata
  • 325
  • 1
  • 2
  • 4

5 Answers5

23

The official Dropbox CLI has an exclude option.

On Linux Dropbox has a client (dropbox) and a deamon (dropboxd).

The client has the exclude command, which you can use to exclude directories. E.g. to exclude node_modules from Dropbox you can enter dropbox exclude add ./node_modules

dropbox help exclude will print the help information:

dropbox exclude [list]
dropbox exclude add [DIRECTORY] [DIRECTORY] ...
dropbox exclude remove [DIRECTORY] [DIRECTORY] ...

"list" prints a list of directories currently excluded from syncing.
"add" adds one or more directories to the exclusion list, then resynchronizes Dropbox.
"remove" removes one or more directories from the exclusion list, then resynchronizes Dropbox.
With no arguments, executes "list".
Any specified path must be within Dropbox.
womble
  • 95,029
  • 29
  • 173
  • 228
muffel
  • 302
  • 7
  • 20
  • 8
    Is there a way to configure without the dropbox daemon running ? – Dimitri Kopriwa Dec 30 '15 at 17:09
  • @BigDong What do you need this for? – Piotr Dobrogost Oct 25 '17 at 16:59
  • 3
    @PiotrDobrogost The problem is that if I have a Dropbox with 500 GB, I have to download all 500 GB before I can apply exclude because the daemon waits for the initial sync to finish before it applies the exclude. Unfortunately, many of us don't have 500 GB on our machines, so we are unable to use this at all. – cgnorthcutt Feb 21 '18 at 17:31
  • @PiotrDobrogost for example: >>>>cgnorthcutt@cpu:~$ python dropbox.py status Syncing (57,278 files remaining) Downloading 57,278 files... >>>>cgnorthcutt@cpu:~$ python dropbox.py exclude list Dropbox isn't responding! – cgnorthcutt Feb 21 '18 at 17:36
  • @BigDong One way I have found to make this work is to execute the command while being in the Dropbox folder e.g: (pretty certain this is same as specifying the absolute path) – cgnorthcutt Feb 21 '18 at 17:43
  • If the single folder you want to keep is at the root of the Dropbox folder, you could do something like `ls | grep -v 'keep-this-directory' | xargs dropbox.py exclude add` – jaygooby Jun 11 '18 at 11:29
  • Or `find . -maxdepth 1 -type d ! -name keep-this-directory -print0 | xargs -0 dropbox.py exclude add` if your other top-level files and folders might contain spaces – jaygooby Jun 11 '18 at 13:25
  • @cgnorthcutt Thank you for pointing out that the `dropbox exclude add 'folder name'` command needs to be issued within the "root" Dropbox folder ==> it bugged me quite a bit (hours on end) after I redo my VPS to get `ext4` file system. – llinfeng Sep 24 '19 at 11:53
  • "excluding from syncing" is not clear. Does this keep dropbox from downloading a file from the server to local while keeping the file on the cloud or does it exclude the file from uploading so that you can keep the local copy without it taking up space on the cloud. (The latter is what I need.) – Kvothe Jan 25 '21 at 17:42
7

I've found the behaviour has changed recently and dropbox exclude now seems to affect the "Selective Sync" i.e "You have a folder on the dropbox cloud that you do not want to sync to the local machine" instead of "You have a folder on the local machine that you do not want to sync to dropbox"

You will want to ignore files instead.

attr -s com.dropbox.ignored -V 1 somefolder
dinosaurwaltz
  • 171
  • 1
  • 1
  • So for this you have to install the `attr` application right? Also if I want to ignore multiple files is there any easy way to use wildcards. I tried `attr -s com.dropbox.ignored -V 1 file_path_*.xml` but it says "A filename to operate on is required". – Kvothe Jan 25 '21 at 17:39
  • Is there something that needs to be done in order to refresh the dropbox and make it drop these files from the cloud? Because I just excluded a large amount of files and it did not affect my used dropbox space. – Kvothe Jan 25 '21 at 17:50
  • Based on this approach, I've recently implemented [dropboxignore](https://github.com/sp1thas/dropboxignore) which is a shell scripts that let's you exclude files and folder using glob patters (like `.gitignore` files). Hope to find it useful. – Panagiotis Simakis Jan 25 '21 at 21:49
5

Imagine a folder on root of Dropbox named "YOURFOLDER"

1 - Tip: cd ~/Dropbox

2 - Press Enter

3 - Tip: dropbox exclude add ~/Dropbox/YOURFOLDER

4 - Press Enter

To confirm

1 - tip: dropbox exclude list

2 - Press Enter

A list of excluded folders will appear:

Excluded: ../../../root/Dropbox/YOURFOLDER

Lucas Catani
  • 51
  • 1
  • 4
1

For the most part the Dropbox CLI works well. Here are a few gotchas I've found with Ubuntu Server (14.04).

  1. For exclude to work properly it helps to be in the Dropbox folder cd ~/Dropbox\ \(blah\)/ and then to exclude the directory ~/Dropbox (blah)$ ~/bin/dropbox.py exclude add /home/<USERNAME>/Dropbox\ \(blah\)/somefolder.
  2. If you exclude a higher level folder, but want to add it back and exclude sub-folders from it, remove the higher level folder from selective sync
Zerodf
  • 111
  • 3
0

This will find and exclude folders ".llgal" from photo gallery of 2016 year:

dropbox exclude add $(find /home/dcp/Dropbox/Galeria_Fotos/2016/ -iname \.llgal | tr '\n' ' ')

I know that is not what you requested but maybe can help other people.

I'm looking for a solution like modifying the database of dropbox, because I have problems with dropbox busy too.

Regards

Oneiroi
  • 2,008
  • 1
  • 15
  • 28
DCP
  • 1