Dropbox CLI: How to whitelist folders for selective sync
A few months ago, after I moved most of my servers to Docker Cloud, I started looking for a backup solution.
More specifically, I needed a container to back up all the data of the other containers. Since I have a lot of space at Dropbox, and they have some neat features such as recovering deleted files and restoring previous versions, I thought Dropbox would be my best choice.
So after a bit of googling, I found some ideas, but none were exactly what I wanted. I wanted to be able to sync exactly one folder, but Dropbox’s CLI only supports excluding files and folders you already uploaded. So I came up with the idea of using a whitelist, i.e. exclude everything except one folder.
First, I used lodatol/cron to run the backup script (backup.sh). This script archives all my data folders and saves them into another folder that’s synced with Dropbox.
Then, I used janeczku/dropbox for the Dropbox CLI and also to run the whitelist script (whitelist.sh). You can see in stackfile.yml how everything fits together as a stackfile.
And that’s how you hack selective sync to work as a whitelist instead of a blacklist. Comment below if you have any questions.
By the way, I keep all my stackfiles on GitHub.