Create a File backup of a DigitalOcean Spaces Object Storage bucket
DigitalOcean Spaces is an S3-compatible object storage service that can be integrated into your Ubuntu VPS using s3fs-fuse
. This guide will walk you through mounting a DigitalOcean Space, securely handling your credentials, automating the mount process, and setting up file backups using SimpleBackups.
Prerequisites
β’ Ubuntu VPS: Ensure your server is running Ubuntu or a distro thatβs compatible with s3fs
.
β’ DigitalOcean Space: Have an existing Space with its Access and Secret Keys.
β’ Root or Sudo Access: Necessary for installing packages and editing system files.
β’ SimpleBackups Account: Sign up at SimpleBackups if you havenβt already.
Step 1: Install s3fs-fuse
s3fs-fuse allows you to mount S3-compatible storage as a local filesystem.
- Update Package List:
sudo apt update
- Install s3fs:
sudo apt install s3fs
Step 2: Securely Store Your Credentials
Storing credentials securely is crucial to maintain system security.
- Create a Directory for Secrets:
mkdir ~/.secrets
- Create the Credentials File:
echo "ACCESS_KEY_ID:SECRET_ACCESS_KEY" > ~/.secrets/dospace-credentials
Replace ACCESS_KEY_ID
and SECRET_ACCESS_KEY
with your actual DigitalOcean Spaces credential.
- Set Appropriate Permissions:
chmod 600 ~/.secrets/dospace-credentials
Step 3: Create a Mount Point
Decide on a directory where the Space will be mounted.
sudo mkdir /mnt/dospace
Step 4: Mount the DigitalOcean Space
Use the s3fs command to mount your Space.
s3fs YOUR_SPACE_NAME /mnt/dospace -o passwd_file=~/.secrets/dospace-credentials -o url=https://YOUR_REGION.digitaloceanspaces.com -o use_path_request_style
Replace:
- YOUR_SPACE_NAME: Name of your DigitalOcean Space.
- YOUR_REGION: Region code of your Space (e.g., nyc3).
Step 5: Verify the Mount
Ensure the Space is mounted correctly.
- Check Mounted Filesystems:
df -h
Look for an entry corresponding to /mnt/dospace.
- List Contents:
ls /mnt/dospace
You should see the contents of your DigitalOcean Space.
Step 6: Automate Mounting at Boot
To ensure the Space mounts automatically after a reboot:
- Edit the
/etc/fstab
File:
sudo nano /etc/fstab
- Add the Following Line:
s3fs#YOUR_SPACE_NAME /mnt/dospace fuse _netdev,passwd_file=/home/your_username/.secrets/dospace-credentials,url=https:
//YOUR_REGION.digitaloceanspaces.com,use_path_request_style 0 0
Replace your_username with your actual username.
- Test the Configuration:
sudo mount -a
Check for any errors and verify the mount as in Step 5.
Step 7: Set Up File Backups with SimpleBackups
With your DigitalOcean Space mounted, you can configure SimpleBackups to back up files to this location.
- Log in to SimpleBackups: Access your SimpleBackups dashboard.
- Connect Your Server:
- Navigate to Servers and click Connect Server.
- Choose the Automatic (SSH Key) method for seamless integration.
- Follow the provided instructions to run the connection command on your Ubuntu VPS.
- Create a New Backup:
- In the dashboard, click Create Backup and select File Backup.
- Enter a name for your backup job.
- Select the server you connected earlier.
- Select Directories to Back Up:
- Specify the directories you wish to back up.
- To back up data to your mounted DigitalOcean Space, choose the appropriate directories within /mnt/dospace.
- Configure Storage:
- Choose SimpleStorage or connect an external storage provider.
- If you prefer to store backups directly in DigitalOcean Spaces, ensure itβs connected as a storage provider in SimpleBackups.
- Set Schedule and Retention:
- Define the backup frequency (e.g., daily, weekly).
- Set retention policies to manage backup storage.
- Save and Enable:
- Review your settings.
- Click Save and enable the backup job.
Security Best Practices
β’ Environment Variables: Alternatively, store credentials in environment variables and reference them in your s3fs command.
β’ AWS CLI Integration: Utilize the AWS CLI credentials file for managing your DigitalOcean Spaces credentials.
β’ Secrets Management Tools: Consider using tools like HashiCorp Vault for enhanced security.
β’ Regular Key Rotation: Periodically rotate your Access and Secret Keys to maintain security.
By following these steps, you can securely mount your DigitalOcean Space on your Ubuntu VPS and configure SimpleBackups to back up your files effectively.