Abdulrahman AlQallaf

Decluttering my mind into the web ...







How to back up Digital Ocean Spaces (S3 compatible storage)

date posted: 2020-Jun-07, last edit date: 2020-Jul-03


Useful resources:

 

STEP 1: In your digital ocean dashboard…

  1. go to account
  2. API
  3. spaces access key
  4. generate new key
  5. save both the access key, and secret key in a text file

STEP 2: Go to your space settings, and add a new entry in the “CORS Configurations” as follows…

  • origin == *
  • allowed methods == GET
  • allowed headers == Access-Control-Allow-Origin

 

STEP 3: Follow the below script on your local machine…

# install required packages
$ sudo apt install s3fs
$ sudo apt install awscli

# store credentials in a file 
# note: file location is important, see man pages for more details
$ echo ACCESSKEY:SECRETKEY > ~/.passwd-s3fs
$ cat ~/.passwd-s3fs

# restrict file permissions
$ chmod 600 ~/.passwd-s3fs
$ ll ~/.passwd-s3fs

# create the location where you want to mount the S3 drive
$ mkdir ~/s3-drive

# mount drive
# note: check that the drive is not already mounted first
$ s3fs -o del_cache -o passwd_file=~/.passwd-s3fs -o use_path_request_style -o url=https://<S3 space name>.<region name>.digitaloceanspaces.com/ <folder name> ~/s3-drive

# check that the drive is mounted
$ mount | grep s3

# step into the drive
$ cd ~/s3-drive

# list all available files
$ aws s3 ls s3://<S3 space name>/ --endpoint=https://<region name>.digitaloceanspaces.com --recursive | less

# copy files needed from bucket to local
$ aws s3 cp s3://<S3 space name>/<path to folder that you want to copy>/ /<local path> --endpoint=https://<region name>.digitaloceanspaces.com --recursive

# unmount drive
fusermount -u ~/s3-drive





# Post Title Date Posted Last Edit Date
1 [Medium Article] 12 Years in Data & AI: Lesson #2 — How Organizational Structure Determines Data & AI Success 2026-03-18 2026-03-18
2 [Medium Article] 12 Years in Data & AI: Lessons Organizations Keep Learning the Hard Way 2026-03-07 2026-03-11
3 [Medium Article] Kuwait's Addition to the FATF Grey List — Why Implementation Matters More Than Regulation 2026-02-18 2026-03-11
4 New tools for data analysis (ipython-sql and Azure Data Studio) 2021-10-16 2021-10-16
5 How to setup a remote jupyter server 2021-10-13 2026-02-02
6 How to setup ZSH 2021-10-12 2021-10-12
7 Concepts in Data Architecture 2021-05-01 2026-02-02
8 Loading data into PostgreSQL reference 2021-03-19 2026-02-02
9 SQLite <--> Pandas reference 2021-03-15 2021-03-15
10 Creating an automated data mart (in SQL) 2020-07-16 2020-07-16
11 Personal finance management and open banking 2020-07-12 2020-07-12
12 Quick SQL reference 2020-07-03 2026-02-02
13 current post -- How to back up Digital Ocean Spaces (S3 compatible storage) 2020-06-07 2020-07-03
14 PostgreSQL initiation 2020-05-25 2020-06-01