Digital Ocean spaces are an object storage service that provides cost-effective, easy storage of large amounts of data secured and safe. Nowadays our several clients approaching us for setting Digital Ocean space backup for their servers. We can now go through setting the Digital Ocean space and setting s3cmd for storage.
Under our Digital Ocean cloud management plan our technical team will assist you to set up your Digital Ocean backup Space and configure backups to Spaces daily or weekly with auto retention.
For this first, you should have a Digital Ocean account, if you don’t have one you can create a new account on the Digital Ocean signup page.
Create a Digital Ocean space
In order to create a new space, you need to click on the “Create” option from the right side of the Digital Ocean control panel. There you can see a “spaces” option in that menu.
Now you can set your requirements for your space, so select the “Region” in which that you need to create the space. If you need to enable CDN for the service you can enable the CDN option there.
There are two options available for “Allow file listing”
1. Restrict file listing :
This option enables the user who connects the space using the access key can list the contents in the space.
2. Enable file listing :
This feature allows anyone to list the contents in the space.
Next, you have to give a name for the space, and also you can assign the space to your projects in the Digital Ocean. Finally, you can create the space by proceeding with the “Create a space” option.
Generate Access Key
In order to access your space from outside of the Digital Ocean, you need to create an access key. An access key is a pair of random tokens that serves as a username and password to grant access to your space.
First, you have to click on the “Space” section on the home page. Then click on the “Generate New Key ” option there and now a “New spaces key” popup window will open. You have to enter your “Key name” there and proceed with the “Generate Key” option.
Now you can see your access key and secret key in the spaces access keys section. The first is your access key and the second one is the secret key.
What is s3cmd?
S3cmd is a free command-line tool that helps clients to upload, retrieve and manage the data in the spaces or any other cloud storage that uses s3 protocol.
Install s3cmd using source
You can download the s3cmd required version source file from the “https://s3tools.org/download” page. Digital Ocean Spaces support only the latest
wget https://webwerks.dl.sourceforge.net/project/s3tools/s3cmd/2.1.0/s3cmd-2.1.0.tar.gz
tar -xzvf s3cmd-2.1.0.tar.gz
cd s3cmd-2.1.0/
sudo python3 setup.py install
You can check the s3cmd version by
s3cmd --version
Initialize the s3cmd configuration
s3cmd --configure
You have to give the following details for s3cmd setup,
1. Enter your access key and secret key there.
2. Give the default space region that you selected.
3. Next you have to enter your space endpoint (You can get this from Digital Ocean –> Space –> settings –>Endpoint).
4. Enter your “DNS-style bucket+hostname”
Eg : %(bucket)s.nyc3.digitaloceanspaces.com
Where;
bucket –> space name
nyc3.digitaloceanspaces.com –> Space endpoint
5. Give the option “Use HTTPS protocol ” as yes
Finally, proceed with the save the settings option.
Here are some s3cmd commands given, you can go through this.
To list all S3 bucket
s3cmd ls
To upload file in the bucket
s3cmd put file.txt s3://sapcebucket name/
To upload a directory in a bucket
s3cmd put -r foldername s3://spacebucket name/
To list data of an s3 bucket
s3cmd ls s3://spacebucket name/
To download files from a bucket
s3cmd get s3://spacebucket name/file.txt
Using s3cmd we can upload the backup of the server to the Digital ocean spaces securely.
If you are facing any issues with setting up backups, contact our technical team providing 24X7 DigitalOcean Support Services.