We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Jeff_S1's avatar
Jeff_S1
Explorer | Level 3
4 years ago

sync only one folder on linux

I have a huge dropbox business account, and I'd like to sync one "deep" folder on a linux client.  This folder is deep in the folder hierarchy, so for example the folder: "folder 1/folder 2/folder 3" is the ONLY one I want downloaded to the linux client.

 

I tried: dropbox.py exclude add * ; dropbox.py exclude remove 'folder 1/folder 2/folder 3'

and various permutations of that, but I always still end up with:

dropbox.py exclude list
Excluded:
folder 1

 

What's the magical set of commands I need to issue to exclude everything - except one deep folder?

Or, do I need to create local paths for this deep folder on the client first?

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Hi Jeff_S1,

    Seems, you are thinking in exactly opposite way instead of what "Selective Sync" implementation assumes to. 🙂 As seems you have noticed (to some extent) that using command (or GUI) folder tend to be excluded, not included, so how exactly you can add a subfolder in a missing (excluded) folder?! 🧐 Try to do the same trick using GUI (not necessary on Linux). Do you able? 🙄 What's the problem? 😉 Using the command prompt is the same! Execute on command line the equivalent things you are doing on GUI. Unchecking particular folder means adding to "exclude list" and checking the same folder means removing from "exclude list". Take in mind that in GUI when you set check mark to a nested folder all containing folders receive check mark too. In console you have to do this by hand! This is NOT done by the control script for you! This could be object of improvements (not to say it's a bug). When adding folders you have to add nested folders from outermost to innermost folder... Or better opposite, instead of exclude all and after that to try add some of them, just exclude folders you don't want to be in sync locally. Nothing special, the same commands (even one less) in right order. 😉

    Hope this gives right direction.

    • Jeff_S1's avatar
      Jeff_S1
      Explorer | Level 3

      Ahh, OK.  This makes sense.  So, I need to include folder 1.  Then exclude all children of folder 1.  Something like:

       

      dropbox.py exclude remove ~/Dropbox/folder 1

      dropbox.py exclude add    ~/Dropbox/folder 1/*

      dropbox.py exclude remove ~/Dropbox/folder 1/folder 2

      dropbox.py exclude add    ~/Dropbox/folder 1/folder 2/*

      dropbox.py exclude remove ~/Dropbox/folder 1/folder 2/folder 3

       

      I'll give that a try...

      • Robert T.26's avatar
        Robert T.26
        Explorer | Level 4

        i just happened to find this old bash script i wrote under ~/Dropbox/.dropbox.cache/old_files/

        Because it was found under /old_files/, it is probably not the best version, so use at your own risk!  Since it does not delete files, only does dropbox exclude operations, it might be safe.  This was written maybe a decade ago.  

         

        Looks like it would give an error because a folder does not exist in the readlink call.  mkdir -p ${T} before looping might be necessary. 

         

        The intent is to automate adding a parent folder of the deeply nested targeted folder folder you want to download. 

        While excluding all other folders brought in when a parent folder is added. 

        I should have a newer version in my old bitbucket files or github or sf, but will take a while to find it.

         

         

        #!/bin/bash
        echo Problems:
        echo dropbox exclude remove ~/Dropbox/DontExcludeMe/MeNeither
        echo does nothing unless its parent directory is first included first.
        echo When the parent directory is included, it brings in all its subfolders and files. 
        echo I smell a tree walk of some kind here.  
        echo Is bash capable of binary trees?
        
        echo Would have to include all the ancestors that do not exist yet
        echo and then add the child directories one-at-a-time
        echo but at the same time, exclude any other directories.  
        
        D=~/Dropbox
        T=~/Dropbox/DontExcludeMe/MeNeither   # T for TARGET
        #mkdir -p ${T}   # May need to uncomment this to precreate the wanted nested folder.
        T2=${T}; 
        
        dropbox exclude remove ${T}  #WONT DO ANYTHING IF PARENT DOES NOT EXIST.
        echo ${T2}; 
        while [ ${D} != ${T2} ]; do J=$(dirname $(readlink -f ${T2} ));  #readlink CAUSES FAILURE WHEN $T DOES NOT EXIST
        	echo readlink CAUSES FAILURE WHEN ${T2} DOES NOT EXIST.  Add code to test for existance of ${T2}.
        	echo ${J}; 
        	echo "We have to filter for the directory target ${T2}, otherwise we add it right back to be excluded!"
        	dropbox exclude remove ${T2}  
        	sync   #Give it a little time to come back.  Should loop for it to be back in existence.
        	find ${T2} -maxdepth 1 -type d -print0 | egrep -v "^${T2}$" | xargs -0 dropbox exclude add
        	T2=$J; 
        done;
        
        #find ${T} -maxdepth 1 -type d -print0 | egrep -v "^${T}$" | xargs -0 dropbox exclude add 

         

         

  • Walter's avatar
    Walter
    Icon for Dropbox Staff rankDropbox Staff
    Hey Jeff_S1; welcome aboard and thanks for using Dropbox!

    Just to make sure we're on the same page, can you please let me know if you're fully synced on this machine by running the status command?

    Keep us posted!
    • Jeff_S1's avatar
      Jeff_S1
      Explorer | Level 3

      No, I have not fully synced.  that would take more than 10TB of data, of which I only need about 600GB (the one deep folder).  I'm trying to avoid that huge, unneeded sync.  So, this is a new, empty machine, that I've installed dropbox.py and activated - but has not synced.