Setup Dropbox On Azure
Setup box on Azure
Setup Dropbox on Azure
We can use dropbox for efficient 2-way project sync!
This approach works for any IDE -
atomorwebstormorvscode- 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 syncvia 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
SourceTreecan simply deal with our local filesystem without any knowledge of the remote filesystem.
Install Dropbox agent
sudo apt install nautilus-dropboxecho "export LC_ALL=en_US.UTF-8 && export LANG=en_US.UTF-8" >> ~/.bashrc && source ~/.bashrc
At this point you should not find any results when you run:
sudo find / -iname dropboxdRun
dropbox start -ito install the daemonIt will get stuck because it's not showing you the logs which give the URL for linking your account
$ dropbox status Starting...Let's find the daemon using:
sudo find / -iname dropboxd... here is an example output:$ sudo find / -iname dropboxd /home/${USER}/.dropbox-dist/dropbox-lnx.x86_64-35.4.20/dropboxd /home/${USER}/.dropbox-dist/dropboxdTo stop the previous process we need its PID. The easiest way to find the PID is to run the same process again and it will tell you the PID of the process that's already running:
# the path and file you found in the previous step $ /home/${USER}/.dropbox-dist/dropboxd ... Another instance of Dropbox (10537) is running!Now kill it:
kill 10537... change10537to be the PID you see in your screen, ofcourse!Now run it in foreground and you will get the account linking URL you need.
copy/paste the url you see in the logs to your browser, follow the instructions
you MUST NOT stop or kill the process while you are linking your account in the browser
eventually the logs will give you a welcome message indicating that account linking its done
$ /home/${USER}/.dropbox-dist/dropboxd ... Please visit https://www.dropbox.com/cli_link_nonce?nonce=secret to link this device. This computer isn't linked to any Dropbox account... Please visit https://www.dropbox.com/cli_link_nonce?nonce=secret to link this device. This computer is now linked to Dropbox. Welcome <user>
Now you should definitely use
ctrl+cto stop the foreground process and check that aDropboxfolder exists:ls -alrt ~/DropboxSince the accounts are linked, start dropbox in background again:
dropbox start -iNOTE:
dropboxdwill start syncing everything in your dropbox account immediately, the next few steps will work to correct this behaviour.But we want to tell
dropboxdto avoid syncing anything other than our code/projects.Switch to your
Dropboxdirectory and exclude any files that it has begun syncing:cd ~/Dropbox/ && dropbox exclude add * && ls -alrt ~/Dropbox && dropbox status
Check the status:
dropbox statusIf its still trying to sync then every few minutes, rerun:
cd ~/Dropbox/ && dropbox exclude add * && ls -alrt ~/Dropbox && dropbox statusAfter the status check declares:
Up to dateRun this command one last time to be sure:
cd ~/Dropbox/ && dropbox exclude add *
Now the contents of your
Dropboxdirectory should be empty:cd ~/Dropbox/ && lsFeel free to take a look at everything which has been excluded:
dropbox exclude listIf the directory you want to sync is also excluded, then remove it from exclude list by
~/bin/dropbox.py exclude remove [DIRECTORY] [DIRECTORY]
Maintainence
Uninstalling dropbox
dropbox stopsudo apt-get remove --purge nautilus-dropboxsudo find / -iname dropboxdremove all the results, for ex:
rm -rf /home/${USER}/.dropbox-dist
sudo find / -iname dropboxrm -rf /home/${USER}/Dropbox/.dropboxrm -rf /home/${USER}/Dropbox/.dropbox.cache
Unlink the machine from your dropbox account by finding its device name at:
https://www.dropbox.com/account/securityin the dropbox account online where it was previously linked and removing it. Otherwise you won't see the following logs to help you unlink from a previous account and relink to a new account if you are hoping to do an uninstall and then a reinstall eventually:This computer isn't linked to any Dropbox account... Please visit https://www.dropbox.com/cli_link_nonce?nonce=secret to link this device.
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:
Unable to monitor entire Dropbox folder hierarchy. Please run "echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p" and restart Dropbox to fix the problem. Unable to monitor entire Dropbox folder hierarchy. Please run "echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p" and restart Dropbox to fix the problem.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!
# how many watchers have been made available? $ cat /proc/sys/fs/inotify/max_user_watches 8192 # how many watchers have been made available? $ sysctl fs.inotify.max_user_watches fs.inotify.max_user_watches = 8192Or you could simply go ahead and make the fix:
# 1. increase the number of watchers $ echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p # 2. stop dropbox daemon if its running $ ~/bin/dropbox.py stop # 3. start the daemon again $ /opt/dropbox/dropboxd & # 4. check the status, it should start humming along again, soon: $ dropbox status Syncing (22,758 files remaining) Indexing 21,025 files... Uploading 1,729 files... $ dropbox status Syncing (21,995 files remaining) Indexing 19,825 files... Uploading 2,166 files...You're welcome ;)
Sync projects via Dropbox
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.
Other References
Last updated