Mounting DigitalOcean Spaces and Access Bucket From Droplet

In this post, I will show you step by step in the easiest way possible how to mount a DigitalOcean Spaces Bucket. Afterwards, you can access it as how you normally access folders on Linux.

The instructions will pretty much work for other S3-compatible storage providers and of course, S3 as well (just some substitutions will be needed).

Note #1: This tutorial assumes that you have a DigitalOcean Spaces bucket, and a Linux server/droplet.

Note #2: If you already have the access & secret keys of your bucket, skip to Step 4.

Step 1

From the Spaces tab on DigitalOcean, click “Manage Keys

Step 1 - DigitalOcean Spaces Credentials

Step 2

Now click “Generate New Key” from the “Tokens/Keys” tab as shown below:

Step 2 - DigitalOcean Spaces Credentials

Step 3

Set a name for your key, then copy the resulting values highlighted below (the ACCESS_KEY_ID and the SECRET_ACCESS_KEY respectively):

Step 3 - DigitalOcean Spaces Credentials

Step 4

On your Linux machine, install the tools3fs-fuse(Ubuntu example below):

sudo apt install s3fs

Step 5

Use the following command to install your DigitalOcean Spaces key on your machine:

echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ${HOME}/.passwd-s3fs && chmod 600 ${HOME}/.passwd-s3fs

In this example, using the values in Step 3, replace ACCESS_KEY_ID:SECRET_ACCESS_KEY by LBIQ652YZFSGJWKWXFKR:XXgVybv8x7Sphgx+42pZtaT5qRrCrseiCCtopagXouo

Step 6

Create the folder where you want to access your bucket:

mkdir -p /media/my-local-bucket

Step 7

Now we just need to mount the bucket on the chosen folder using this single command:

s3fs my-awesome-space /media/my-local-bucket \
-o passwd_file=${HOME}/.passwd-s3fs \
-o url= \
-o use_path_request_style

This command mounts our DigitalOcean Spaces bucket named my-awesome-space on the folder /media/my-local-bucket in Linux.

Note: in our example, the bucket is located in nyc3 region. If your bucket is in another region, make sure you replace nyc3 by the correct region. You can find the region and the bucket name as shown below:

Step 7 (Name and Region of Bucket) - DigitalOcean Spaces Credentials

Verify That It Works

Finally, you can check the local folder /media/my-local-bucket to verify that it has your DigitalOcean Spaces bucket files and folders! 👏

ls -lah /media/my-local-bucket

Verify That It Works - DigitalOcean Spaces Credentials

Step 8 — Confirmation

In the screenshot above, we locally see the same files and folders seen earlier in Step 7 — this verifies that we can access the bucket as a local folder.

*If you are still unable to make it work repeat the steps and make sure you set the right Bucket region / name.*

You can create a free SimpleBackups account and effortlessly back up your databases, servers and websites with the ability to choose DigitalOcean Spaces and other storage providers as a storage option! Try it out.

Back to blog

Ready to automate your backups?

Sign up for FREE. Get started in less than one minute.

Secure your backups

No credit card required. Free 14-day trial.