Tutorial rapido su rclone per Object Storage GARR¶
Rclone è un programma a riga di comando per sincronizzare file e directory verso e da diversi provider di object storage, incluso (ma non limitato a) servizi basati su OpenStack Swift e S3.
Configurazione¶
In questo breve tutorial assumiamo che tu voglia accedere al GARR Object Storage tramite protocollo S3.
Prima di tutto devi scaricare le credenziali EC2 per il tuo progetto e utente:
- Accedi alla dashboard
- Clicca sulla scheda Progetto -> Compute -> Accesso & Sicurezza
- Clicca sulla scheda Credenziali API
- Clicca sul pulsante Scarica Credenziali EC2
Il file scaricato ec2rc.sh contiene le variabili d'ambiente EC2_ACCESS_KEY e EC2_SECRET_KEY (e anche EC2_URL sebbene questo sarà ignorato nella configurazione seguente).
Sulla tua macchina Linux client, ora puoi avviare rclone config e seguire le risposte evidenziate sotto (nota che per il parametro endpoint devi specificare l'URL appropriato per la tua regione cloud, vedi la tabella in fondo a questa pagina).
$ rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> garr-s3
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Alias for a existing remote
\ "alias"
2 / Amazon Drive
\ "amazon cloud drive"
3 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
4 / Backblaze B2
\ "b2"
5 / Box
\ "box"
6 / Cache a remote
\ "cache"
7 / Dropbox
\ "dropbox"
8 / Encrypt/Decrypt a remote
\ "crypt"
9 / FTP Connection
\ "ftp"
10 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
11 / Google Drive
\ "drive"
12 / Hubic
\ "hubic"
13 / HTTPConnection
\ "http"
14 / Local Disk
\ "local"
15 / Mega
\ "mega"
16 / Microsoft Azure Blob Storage
\ "azureblob"
17 / Microsoft OneDrive
\ "onedrive"
18 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OvH)
\ "swift"
19 / Pcloud
\ "pcloud"
20 / QingCloud Object Storage
\ "qingstor"
21 / SSH/SFTP Connection
\ "sftp"
22 / Webdav
\ "webdav"
23 / Yandex Disk
\ "yandex"
Storage> 3
Choose your S3 provider.
Choose a number from below, or type in your own value
1 / Amazon Web Services (AWS) S3
\ "AWS"
2 / Ceph Object Storage
\ "Ceph"
3 / Digital Ocean Spaces
\ "DigitalOcean"
4 / Dreamhost DreamObjects
\ "Dreamhost"
5 / IBM COS S3
\ "IBMCOS"
6 / Minio Object Storage
\ "Minio"
7 / Wasabi Object Storage
\ "Wasabi"
8 / Any other S3 compatible provider
\ "Other"
provider> 2
Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).
Only applies if access_key_id and secret_access_key is blank.
Choose a number from below, or type in your own value
1 / Enter AWS credentials in the next step
\ "false"
2 / Get AWS credentials from the environment (env vars or IAM)
\ "true"
env_auth> 1
AWS Access Key ID.
Leave blank for anonymous access or runtime (env var), or if you want to use the credentials specified in the ~/.aws/credentials.
Enter a string value. Press Enter for the default ("").
access_key_id> xxxxxxxxxxxxxxxxxx
AWS Secret Access Key (password)
Leave blank for anonymous access or runtime (env var), or if you want to use the credentials specified in the ~/.aws/credentials.
Enter a string value. Press Enter for the default ("").
secret_access_key> yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
Region to connect to.
Leave blank if you are using an S3 clone and you don't have a region.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Use this if unsure. Chosen by default.
\ ""
2 / The default endpoint - a good choice if you are unsure.
\ "us-east-1"
region>
Endpoint for S3 API.
Required when using an S3 clone.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
endpoint> https://object-store.cloud.garr.it:8080
LocationConstraint - must be set to match the Region.
Leave blank if not sure. Used when creating buckets only.
Enter a string value. Press Enter for the default ("").
location_constraint>
Canned ACL used when creating buckets and storing or copying objects.
This ACL is used for creating objects and if bucket_acl isn't set, for creating buckets too.
For more info visit https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
Note that this ACL is applied when server side copying objects as S3
doesn't copy the ACL from the source but rather writes a fresh one.
Choose a number from below, or type in your own value
1 / Owner gets FULL_CONTROL. No one else has access rights (default).
\ "private"
2 / Owner gets FULL_CONTROL. The AllUsers group gets READ access.
\ "public-read"
3 / Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access.
\ "public-read-write"
4 / Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.
\ "authenticated-read"
5 / Object owner gets FULL_CONTROL. Bucket owner gets READ access.
\ "bucket-owner-read"
6 / Object owner gets FULL_CONTROL. Bucket owner gets FULL_CONTROL.
\ "bucket-owner-full-control"
acl> 1
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n
Remote config
--------------------
[garr-s3]
type = s3
provider = Ceph
env_auth = false
access_key_id = xxxxxxxxxxxxxxxxxx
secret_access_key = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
endpoint = https://object-store.cloud.garr.it:8080
acl = private
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
garr-s3 s3
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
Utilizzo¶
Ora puoi usare il remote configurato garr-s3.
Elenca i bucket:
rclone listremotes garr-s3:
Crea un nuovo bucket:
rclone mkdir garr-s3:mybucket
Copia un file locale nel bucket remoto:
rclone copy /path/to/local/file garr-s3:mybucket
Elenca il contenuto del bucket remoto:
rclone ls garr-s3:mybucket
Copia un file remoto in locale:
rclone copy garr-s3:mybucket/file /path/to/local/dir
Ulteriori dettagli sull'utilizzo sono disponibili su https://rclone.org/docs/
Regioni ed Endpoint¶
L'endpoint da usare dipende dalla regione Cloud GARR su cui è allocato il tuo progetto. Puoi trovare questa informazione sulla dashboard, in Compute -> Overview. A seconda della regione, usa il valore Endpoint corrispondente nella configurazione rclone.
| Regione | Endpoint |
|---|---|
| garr-pa1 | https://object-store.cloud.garr.it:8080 |
| garr-ct1 | https://object-store.cloud.garr.it:8080 |