If you’re looking for an affordable and reliable way to store your data, DigitalOcean Spaces may be a good option for you. Spaces is a new storage service from DigitalOcean that allows you to use the company’s servers to store your files. To get started, first create an account on DigitalOcean and then create a space. A space is a collection of servers that you can use to store your files. You can create as many spaces as you need and they all have the same price: $5 per month. Once you’ve created your space, you’ll need to add some servers to it. To do this, click on the “Servers” tab in your space’s overview page and then select “Add Server.” You can add any of DigitalOcean’s servers, which have been pre-configured with Spaces enabled. Once you’ve added your servers, go ahead and start uploading your files. Spaces will automatically detect the files that are in your source directory (the directory where the files are stored on the server) and will put them into storage on the server. You can also use the “Upload Files” button on your space’s overview page to upload multiple files at once. Spaces is a great option if you’re looking for an affordable way to store your data outside of Amazon S3 or Google Drive. It’s easy to use and has low monthly fees, making it a great choice for small businesses or individuals who don’t need unlimited storage capacity. ..
$5 per month 250 GB of storage space 1 TB of outbound transfer Unlimited uploads Creation of unlimited number of spaces
In this article, we are going to explore how to get started with DigitalOcean Spaces and some common operations that would be used.
Creating a Space
Once you have signed into DigitalOcean and chosen to create a new Space, you will be presented with the options to provision your Space. You will need to determine the following:
Datacenter Region Whether to Enable CDN or not Allow or Restrict File Listing Decide on a Name for the Space
In this example, we are choosing to create the space in Datacenter Region 2, San Francisco, enable the CDN (without a custom subdomain), and restrict the anonymous file listing.
Finally, we will choose a unique name, lc-articles in this case, and whether to place it into a project. Next we will click on the Create a Space button to provision our Space.
With out newly created Space, you will see that there are no files but through the interface, we can easily upload files or create folders as necessary.
Clicking on Settings shows all the configurations that we can modify. Several additional features here are very useful. Notably the Purge Cache option and the CORS configurations.
Generate Spaces Access Keys
Navigate to the Account → API section and under the Tokens/Keys section find the Generate New Key option for Spaces access keys.
Enter a name to identify the access key. Once saved, you will be presented with the key and the associated secret.
We will use these two values to connect to the DigitalOcean Space that we created.
Configure S3Cmd
In this article we are going to use the popular S3Cmd tool to upload files from an Ubuntu server. After installing S3Cmd, which can be done in Ubuntu using apt install s3cmd, we will need to create a configuration file. The easiest way to get started is to use the s3cmd –configure command. There are a number of different settings that we need to configure.
Access Key – The same access key as created on the API token page. Secret Key – The same secret key as created on the API token page. Default Region – Left as the default US in this example. S3 Endpoint – This will be the same endpoint as shown on the settings page for the Space. DNS Based Bucket Syntax – Instead of the default value, this should reflect the correct endpoint: %(bucket)s. {region}. digitaloceanspaces. com. Replace {region} with the correct value as shown on the settings page. Encryption Password – Left as blank in this example. GPG Program Path – Left to use the default GPG program path. HTTPS Protocol – Left to use the default of using the HTTPS protocol. Proxy – Left as the default of no proxy connection.
It is also wise to use the test connection option to make sure the settings are correct before saving the configuration file.
We can verify that this works by simply running the command s3cmd ls. If we see the output of our newly created Space (bucket in S3 parlance), then we know that the connection is working.
Uploading Files
The first operation that we are going to demonstrate is that of uploading a files or files to our Space. The command to upload a file is very simple:
As you can see from the above screenshot, the file has been successfully uploaded. Additionally, you can verify this in the GUI as well.
Listing Files
How can we list what available files are currently located in the Space? Much like the standard Linux command of ls, we use a similar one with S3Cmd.
To retrieve additional information about a given file in the Space., we can use the info command to list the metadata associated with the item.
Removing Files
Removing files is just as easy as the prior operations. Now that we have uploaded our file, been able to list that file, we can use the path returned to allow us to delete the file.
As you can see, we have deleted the testfile1.zip and verified, via the command line, that the file is no longer listed within the Space. Furthermore, if we check the GUI, we can see that the file has also been shown as removed.
Conclusion
DigitalOcean Spaces offers a compelling mix of low-cost functionality that will fit many of the needs of a system administrator looking to make use of a low-cost storage location. Since DigitalOcean is generally geared towards rapid development and robust production services, having the ability to quickly store large files, accessible to multiple servers, is a convenient and often used ability.
One of the most popular use cases is that of storing system backups here. If you use a traditional method of backing up, such as creating a TAR or ZIP file, then you can easily transfer those files in a script to a DigitalOcean Space. Check out how quick it and easy it is to get started on the DigitalOcean site!