How to Exclude/Include Folders in Dropbox CLI on Linux Server: Selective Sync Guide


1 views

When managing Dropbox on a Linux server without GUI, the built-in selective sync feature requires CLI alternatives. The standard GUI method of right-clicking the Dropbox icon won't work in server environments.

Ensure you have:

  • Dropbox daemon properly installed
  • Command-line access with sufficient privileges
  • Basic familiarity with Linux file operations

Dropbox provides a Python script for selective sync management:

wget -O ~/dropbox.py https://www.dropbox.com/download?dl=packages/dropbox.py
chmod +x ~/dropbox.py

First, check which folders are currently syncing:

~/dropbox.py exclude list

This outputs paths relative to your Dropbox folder.

To exclude a folder (and its contents):

~/dropbox.py exclude add /Path/To/Folder

Example excluding a "Videos" folder:

~/dropbox.py exclude add ~/Dropbox/Videos

To resume syncing an excluded folder:

~/dropbox.py exclude remove /Path/To/Folder

The folder will begin syncing during the next Dropbox daemon cycle.

For advanced users, you can directly modify the config file:

nano ~/.dropbox/info.json

Locate the "excluded" array and modify paths as needed. Restart Dropbox after changes:

dropbox stop && dropbox start

Create a bash script to manage exclusions:

#!/bin/bash
# Sync only project folders
~/dropbox.py exclude add ~/Dropbox/*
~/dropbox.py exclude remove ~/Dropbox/ProjectA
~/dropbox.py exclude remove ~/Dropbox/ProjectB

Common issues and fixes:

  • Changes not reflecting: Wait 5-10 minutes or restart Dropbox
  • Permission errors: Run as the same user that owns Dropbox
  • Script not found: Verify the path to dropbox.py

While Dropbox's GUI provides intuitive folder selection for syncing, server administrators often need command-line control. The official Dropbox CLI offers powerful alternatives to GUI operations.

First ensure you have:

  • Dropbox daemon running (dropbox start)
  • Python installed (required for CLI tools)
  • Proper permissions for the Dropbox folder

To view your current sync configuration:

dropbox filestatus

or for detailed output:

dropbox filestatus -l

Use the exclude command to prevent specific folders from syncing:

dropbox exclude add ~/Dropbox/LargeMedia
dropbox exclude add ~/Dropbox/Development/NodeModules

To resume syncing an excluded folder:

dropbox exclude remove ~/Dropbox/ImportantProject

For batch operations, combine with shell commands:

# Exclude all folders matching pattern
find ~/Dropbox -type d -name "temp_*" -exec dropbox exclude add {} \;

# List all excluded folders
dropbox exclude list

Check if your changes took effect:

dropbox status
dropbox filestatus ~/Dropbox/Path/To/Folder

Create a bash script for consistent setup across servers:

#!/bin/bash
# Configure Dropbox sync preferences
dropbox exclude add ~/Dropbox/Backups
dropbox exclude add ~/Dropbox/Scratch
dropbox exclude remove ~/Dropbox/Projects/Active
echo "Dropbox sync configuration complete"
  • If changes don't persist, restart the daemon: dropbox stop && dropbox start
  • For permission errors, verify ownership: sudo chown -R $USER:$USER ~/Dropbox
  • Check logs with: tail -f ~/.dropbox/dropbox.log

For programmatic control, consider the official API (Python example):

import dropbox
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')

# List folder contents excluding specific patterns
result = dbx.files_list_folder('', recursive=True)
for entry in result.entries:
    if isinstance(entry, dropbox.files.FolderMetadata):
        if 'exclude' in entry.name.lower():
            print(f"Would exclude: {entry.path_lower}")