Dropbox is a folder synchronization product that takes a folder (eponymously called Dropbox) and makes sure it’s identical across all devices. This folder is also available on the web and there are robust sharing options. Dropbox was one of the first in this space, before Google Drive and Microsoft’s OneDrive. They support all major operating systems including Linux, and also offer a headless client. In this tutorial, we’ll look at running Dropbox headless on your Linux VPS.
Why Use Dropbox on a VPS?
While most people use Dropbox to synchronize their personal files, documents, and media, as well as back them up to the cloud, there are ways to exploit Dropbox’s abilities on your VPS.
- Backups are as simple as creating files in ~/Dropbox
- File distribution is dead simple when you have a directory that is identical everywhere
- You can have a job that watches for files in certain folders and handles them, whether it be as jobs to be executed, media to be processed, etc.
- Any media or data that originates in the cloud can easily and automatically be transported home
Preparing for Install
First, if you haven’t done so, you’ll need to sign up on Dropbox.com. Accounts are free with a small quota, and of course if you choose you can buy more storage.
You’ll need some prerequisites before you can install Dropbox. On a Debian 10 system, these can be satisfied with a single command:
apt install libglib2.0 libxdamage1 libglapi-mesa libxcb-glx0 libxcb-dri2-0 libxcb-dri3-0 libxcb-present0 libxcb-sync1 libxshmfence1 libxxf86vm1
Next, you’ll need to increase the number of inotify watches. Dropbox is constantly monitoring in the background for new files, deleted files, changed directories, etc. so it needs to have many watches. You can setup more watches like this:
echo fs.inotify.max_user_watches=100000 >> /etc/sysctl.conf sysctl -p
Installing the Dropbox Daemon
There are two things you’ll need:
- The dropboxd daemon
- dropbox.py, a command-line interface program
Start by downloading the daemon. You do not need to be root to set this up, and I prefer to run Dropbox as an unprivileged user. In /home/raindog308 I ran these commands:
wget -O dropbox-linux-x86_64.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64 tar xzf dropbox-linux-x86_64.tar.gz
Once you do this, the .dropbox-dist is created.
Now you can run the Dropbox daemon. We’ll automate this later, but since you need to link your device, do it manually the first time:
~/.dropbox-dist/dropboxd
After a few moments, you’ll see a message like this:
Please visit https://www.dropbox.com/cli_link_nonce?nonce=XXXxxxXXXxxxXXX to link this device.
Click the link and then click Connect.
The daemon is still running (in the foreground). You can hit control-C to stop it. Below you can see how to start it via systemd.
Installing the Dropbox CLI
The Dropbox CLI program is a Python program that offers many commands. All you ned to do is download it:
wget -O /usr/local/bin/dropbox.py https://www.dropbox.com/download?dl=packages/dropbox.py chmod 755 /usr/local/bin/dropbox.py
I’d recommend putting it somewhere in your path – perhaps in /usr/local/bin.
If you execute it, you’ll see everything it can do:
raindog308@server1:~$ ./dropbox.py Dropbox command-line interface commands: Note: use dropbox help <command> to view usage for a specific command. autostart automatically start Dropbox at login exclude ignores/excludes a directory from syncing filestatus get current sync status of one or more files help provide help lansync enables or disables LAN sync ls list directory contents with current sync status proxy set proxy settings for Dropbox puburl get public url of a file in your Dropbox's public folder running return whether Dropbox is running sharelink get a shared link for a file in your Dropbox start start dropboxd status get current status of the dropboxd stop stop dropboxd throttle set bandwidth limits for Dropbox update download latest version of Dropbox version print version information for Dropbox
Using the Dropbox CLI
One thing you may already be thinking is that you don’t want your entire Dropbox folder on a VPS. The way to prevent this is to exclude folders. The syntax may be counter-intuitive to you. “exclude add” means “add to the exclude list” not “add it to syncing”. For example, if you have a folder called LowEndSecrets, you could exclude it like this:
raindog308@server1:~/Dropbox$ dropbox.py exclude add LowEndSecrets Excluded: LowEndSecrets
Then use “exclude list” to see what’s excluded:
raindog308@server1:~/Dropbox$ ../dropbox.py exclude list Excluded: LowEndSecrets
And to reverse this:
raindog308@server1:~/Dropbox$ ../dropbox.py exclude remove LowEndSecrets No longer excluded: LowEndSecrets
If you want to see synchronization status, use the “status” command:
raindog308@server1:~/Dropbox$ ../dropbox.py status Syncing 157,389 files • 2+ days Indexing 584 files (1 min) Uploading 1 file... Downloading 156,804 files (13.8 KB/sec, 2+ days)
(Note that in this example the slow sync rate is because this was a fresh install and Dropbox was busy synchronizing).
Here is an example a little while later once Dropbox was fully synchronized:
raindog308@server1:~/Dropbox$ ../dropbox.py status Up to date
To see the status of one folder, use “filestatus”:
raindog308@server1:~/Dropbox$ ../dropbox.py filestatus Travel Travel: syncing raindog308@server1:~/Dropbox$ ../dropbox.py filestatus Travel Travel: up to date
Automating Dropbox Startup
You can use systemd to automate Dropbox start/stop. Here’s a sample unit file. Place this in /etc/systemd/system/dropbox.service:
[Unit] Description=Dropbox After=network.target [Service] User=raindog308 ExecStart=/usr/local/bin/dropbox.py start ExecStop=/usr/local/bin/dropbox.py start Type=forking [Install] WantedBy=multi-user.target
Then simply:
systemctl daemon-reload systemctl enable dropbox systemctl start dropbox
Related Posts:
- MetWeb has a 30% Off Deal on Cheap VPS Offers in Utah for Our Readers! - December 21, 2024
- Is Your Soul as Dark as a Christmas Stocking’s Coal?Make Your Online World Match - December 20, 2024
- Hosteroid has a HOT, Limited Stock Offer in Vienna or Amsterdam! - December 19, 2024
Leave a Reply