Dropbox
Setup box
Shared FileSystem
Dropbox
We can use dropbox for efficient 2-way project sync!
This approach works for any IDE -
atom
orwebstorm
orvscode
- they don't have to know about the remote filesystem.This will allow us to write code locally and have the changes show up on the remote box.
Adding/deleting files will work
File permissions will be properly reflected
Configuring
selective sync
via the dropbox UI will prevent the transfer of bulky dependencies back to your local filesystemsuch features are often difficult to setup or absent in other sync tools.
Tools like
SourceTree
can simply deal with our local filesystem without any knowledge of the remote filesystem.
Install Dropbox agent
for digitalocean 64-bit droplets with Ubuntu OS:
Link the machine by copy/pasting the URL from the output window into your browser. Here's a sample of what you'll see:
Once you are done linking, you will see the following output:
Leave the terminal window with
dropboxd
running in the foreground, as-is.NOTE:
dropboxd
will start syncing everything in your dropbox account immediately, the next few steps will work to correct this behaviour.
Open a new
ssh
session with your remote machine and download thedropbox.py
command-line tool so we may telldropboxd
to avoid syncing anything other than our code/projects.Switch to your
Dropbox
directory and exclude any files that it has begun syncing:Check the status:
~/bin/dropbox.py status
If its still trying to sync then every few minutes, rerun:
cd ~/Dropbox/ && ~/bin/dropbox.py exclude add *
Keep running the status check again too:
~/bin/dropbox.py status
After the status check declares:
Up to date
Run this command one last time to be sure:
cd ~/Dropbox/ && ~/bin/dropbox.py exclude add *
Now the contents of your
Dropbox
directory should be empty:cd ~/Dropbox/ && ls
Feel free to take a look at everything which has been excluded:
~/bin/dropbox.py exclude list
If the directory you want to sync is also excluded, then remove it from exclude list by
~/bin/dropbox.py exclude remove [DIRECTORY] [DIRECTORY]
Now that we've excluded everything known to us, you can place any new code-related projects & folders into dropbox and they will sync between.
https://www.digitalocean.com/community/questions/dropbox-works-with-digitalocean-droplets
You probably don't want to host content out of your Dropbox folder, but there's a basic trick for mirroring Dropbox content outside of the Dropbox folder: create a symbolic link.
Example: ln -s /var/www/foo.com ~/Dropbox/foo.com
This will cause Dropbox to treat /var/www/foo.com as if it resided inside the Dropbox folder. All other clients will see foo.com as a folder within the Dropbox folder, and will transparently sync across that symlink.
We cannot count on keeping our first ssh session alive forever to run
dropboxd
so let's set it up as a serviceAs a safety measure, I forked
thisismitch
's gist in case it ever gets taken down.
As a convenience, on your remote box, you can edit
~/.bashrc
to add an alias:this will let you use shorthand like
dropbox status
instead of~/bin/dropbox.py status
If you code using dropbox for sync long enough, you will run into an issue where dropbox will either crash or hang or both because of a limit on maximum number of files it can monitor for changes.
If you are lucky then the logs will magically pop-up on your console stating:
You can protect against this by understanding what is going on. For example I found out that I had provided significantly less resources than what dropbox recommends!
Or you could simply go ahead and make the fix:
You're welcome ;)
Other References
Last updated