How to Backup Important Files to Dropbox on Ubuntu Linux

laptop 4662049 640
laptop 4662049 640

Looking for an easy way to back up your Ubuntu 16.04 LTS servers’ files to Dropbox? These can be your website content, important configuration files, and other important files you can’t afford to lose. This process backs them all automatically to Dropbox.

This brief post will show students and new users how to install and configure Dropbox on Ubuntu 16.04 LTS Servers (headless) to automatically back up essential configuration files and website content. This process can be an affordable way to get your content secured.

To get started with backing up your files via Dropbox, continue with the steps below:

Install Dropbox on Ubuntu

Before getting the backup process to work, you must download and install Dropbox. Run the commands below to download Dropbox 64-bit package for 64-bit systems.

cd /tmp && wget https://www.dropbox.com/download?plat=lnx.x86_64 -O dropbox-linux.tar.gz

The 32-bit version of the package can be found below

cd /tmp && wget https://www.dropbox.com/download?plat=lnx.x86 -O dropbox-linux.tar.gz

After downloading the package, run the commands below to extract.

tar xvf dropbox-linux.tar.gz

After extracting the downloaded package, run the commands below to move the content to a location in the /opt/dropbox directory.

sudo mv .dropbox-dist /opt/dropbox

Next, run the commands below to allow dropbox to authenticate the server

/opt/dropbox/dropboxd

This should launch a dropbox script to allow you to authenticate the servers. You should see links on the screen to select and paste into your web browser. Then click Connect button to log on to dropbox and authenticate. After that, the server can upload and download content from your Dropbox account.

This computer isn't linked to any Dropbox account.
Please visit https://www.dropbox.com/cli_link_nonce?nonce=33e0533aa1f33af160154eeb9304703d to link this device.
This computer isn't linked to any Dropbox account.
Please visit https://www.dropbox.com/cli_link_nonce?nonce=33e0533aa1f33af160154eeb9304703d to link this device.
This computer isn't linked to any Dropbox account.
Please visit https://www.dropbox.com/cli_link_nonce?nonce=33e0533aa1f33af160154eeb9304703d to link this device.
This computer isn't linked to any Dropbox account.
Please visit https://www.dropbox.com/cli_link_nonce?nonce=33e0533aa1f33af160154eeb9304703d to link this device.
This computer isn't linked to any Dropbox account.
Please visit https://www.dropbox.com/cli_link_nonce?nonce=33e0533aa1f33af160154eeb9304703d to link this device.

Click Connect

ubuntu dropbox

Create Dropbox Service

Dropbox is installed and ready to use. However, it would be easier to manage if it was a service account. To create a Dropbox service account, run the commands below

sudo nano /etc/systemd/system/dropbox.service

Then copy the content below and paste it into the file.

[Unit]
Description=Dropbox
After=network.target

[Service]
Type=simple
User=your_ubuntu_user_name_here
ExecStart=/opt/dropbox/dropboxd
ExecStop=/bin/kill -HUP $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target

Save the file and exit.

Now you should be able to run the commands below to stop, start and enable Dropbox to start up when the server starts automatically.

sudo systemctl stop dropbox.service
sudo systemctl start dropbox.service
sudo systemctl enable dropbox.service

Backing Up to Dropbox

At this stage, Dropbox is installed, and a folder called Dropbox is created in your home directory. When you go back to automatically backup content, place the content in the ~/Dropbox folder in your home directory, and it should be backed up to Dropbox.

You can also create symbolic links to backup directories and files. for example, to back up the entire document root for Apache2 and Nginx (/var/www/html/), you can run the commands below

ln -s /var/www/html ~/Dropbox

You can do this for any file and directory. So, for example, everything created in the /var/www/html will automatically be backed-up to Dropbox.

Enjoy!~

You may also like the post below:

Posted by
Richard W

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

4 Comments

  1. Nice post!
    How to use selective folder sync?

    1. mkdir -p ~/bin
      wget -O ~/bin/dropbox.py “http://www.dropbox.com/download?dl=packages/dropbox.py”
      chmod 755 ~/bin/dropbox.py
      ~/bin/dropbox.py help

      ~/bin/dropbox.py exclude add FOLDER

  2. Hello,

    I would like to send the backup in a file that includes tar.gz it’s possible?

    Thanks

  3. I have followed until creating symbolic links.. but, how to sync existing files and folders into dropbox? can provide further commands to copy files and folders from /var/www/html to dropbox, please? Thank you

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: