📜 ⬆️ ⬇️

[Translation] We simplify the work with the server using selective synchronization in Dropbox

Many people like Dropbox because of the simple and instant file synchronization between devices, and those who work with their website or blog know that often receiving files from servers causes an extra headache ... Dropbox was created to solve this problem, just for this you need a little resourcefulness .

In this tutorial, we will set up Dropbox on your server to selectively synchronize files so that these files are available anywhere and your life becomes easier.

Let's start


')
This guide assumes that Ubuntu is used on your server, but this method may work on other distributions with minor changes. I have simple servers on Amazon EC2 and Linode, and if you are just starting out, you can use them.

In this article, I will show the basic steps so that you do not have to search for most of the information on the entire Internet in search of a solution that I used.

Step 1: Go to your local Dropbox folder and create a folder with the name Server, or name it as you please, but if the name is different, you will need to remember it.

Install Dropbox



Step 2: Now connect to your server via SSH. Let's check if you have a 32-bit or 64-bit system on your server.

uname -m

If you see that you have x86_64:

cd ~ && wget -O - "http://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

If you see that you have i686:

cd ~ && wget -O - "http://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

Step 3: Download a useful Python script so that we can manage Dropbox and the bash script that we will use to start and stop Dropbox.

mkdir ~/utils

wget -O ~/utils/dropbox.py www.dropbox.com/download?dl=packages/dropbox.py

chmod 755 ~/utils/dropbox.py

wget -O ~/utils/dropbox_temp "https://raw.github.com/gist/2347727/108fc8af551cb4fdf7cdd08b891a45f405d283dc/dropbox"


Step 4: Launch the Dropbox daemon from the newly created .dropbox-dist folder

~/.dropbox-dist/dropboxd

Step 5: Dropboxd will display the message “This client is not linked to any account ...” and give you a link, copy and paste it into your web browser and authenticate and test the new connection.

Step 6: After Dropbox connects to the server, kill the daemon with Ctrl-C.
Now that Dropbox is linked, install it as a service in Ubuntu.

Step 7: First edit the script and replace “user1 user2” with your server username ( but not your login with Dropbox ). Then we move it to the right place, set the appropriate rights and add it to the autoload.

nano ~/utils/dropbox_temp
sudo mv ~/utils/dropbox_temp /etc/init.d/dropbox
sudo chmod +x /etc/init.d/dropbox
sudo update-rc.d dropbox defaults


Check if Dropbox is running, if not, launch it.

sudo service dropbox status
sudo service dropbox start


It is working



~/utils/dropbox.py status
-> Downloading 3,134 files (0.1 KB/sec, a long time left.
Grab a Snickers)


Oops! Dropbox now syncs all the content of Dropbox to your server, for me it is not very good, so let's eliminate it using selective sync.

Selective Sync



Step 8: You need to type the 'exclude add' command for those top-level directories that you don’t want to sync, I suggest starting by excluding the largest directory so that Dropbox and your server do not do any extra work.

cd ~/Dropbox
~/utils/dropbox.py ls
-> Photos Projects Public Server Work

~/utils/dropbox.py exclude add Projects
~/utils/dropbox.py exclude add Photos
~/utils/dropbox.py exclude add Public
~/utils/dropbox.py exclude add Work
~/utils/dropbox.py ls
-> Server


Happened?



Go to the Dropbox directory in your home directory on the server, create a file in it to check.

cd ~/Dropbox/Server
echo 'success' > success.txt


Check your Dropbox folder on your local computer, if the success.txt file has appeared - you are connected!

Happened!



Directory synchronization works in both directions, make changes, add a new file, and you will see it on your server almost instantly.

This article is a translation. The original is available by reference .

Source: https://habr.com/ru/post/144178/


All Articles