Rclone
Rclone is a command-line interface for working with objects in S3.
Configure Rclone
1. Configure S3 access
Access can be configured by the Account Owner or a user with the iam.admin role.
- Create a service user with a role with access to S3. If you use a service user with the
s3.user,object_storage_userors3.bucket.userrole, the bucket must have a configured access policy and its rules must allow access to this user. - Issue an S3 key to the user.
2. Install the client
For compatibility with Servercore, Rclone version v1.69 or higher is required.
Windows
Linux/macOS
-
On the Rclone website, download the distribution package for Windows.
-
Unpack the distribution archive.
-
Open the command prompt.
-
Navigate to the directory containing the distribution:
cd <path>Specify
<path>— the path to the directory with the distribution package.
3. Create an Rclone configuration
-
Make sure that Virtual-Hosted addressing is enabled in the bucket.
-
Open the configuration mode:
rclone configA dialog will appear in the console:
No remotes found, make a new one?n) New remotes) Set configuration passwordq) Quit config -
Create a new configuration:
n/s/q> n -
Enter the remote storage connection name (for example,
servercore_s3):name> servercore_s3 -
Enter the storage type specified after the line
Amazon S3 Compliant Storage Providers including ..., Servercore, ...:Storage> s3 -
Enter the provider type specified after the line
Any other S3 compatible provider:provider> Servercore -
Select the authentication method specified after the line
Enter AWS credentials in the next step:env_auth> false -
Enter
AWS Access Key ID:access_key_id> <access_key>Specify
<access_key>— the value of the Access key field from the S3 key. -
Enter
AWS Secret Access Key (password):secret_access_key> <secret_key>Specify
<secret_key>— the value of the Secret key field from the S3 key. -
Enter the pool where S3 is located (for example,
ru-1):region> <pool> -
Enter the URL for S3 API access:
endpoint> <s3_domain>Specify
<s3_domain>— the S3 API domain. The domain depends on the pool where S3 is located. -
Leave the
location_constraintparameter blank. -
Leave the
aclparameter blank. -
Leave the
Edit advanced configparameter blank or entern. -
Verify the configuration:
Remote config--------------------[servercore_s3]type = s3provider = Servercoreenv_auth = falseaccess_key_id = <access_key>secret_access_key = <secret_key>region = <pool>endpoint = <s3_domain>--------------------y) Yes this is OKe) Edit this remoted) Delete this remoteIf the configuration is correct, press Enter. If not, enter
eand edit the configuration. -
Confirm the configuration creation:
y/e/d> y -
Exit the settings dialog:
e/n/d/r/c/s/q> q
Working with Rclone
Command format
General command structure:
<command> <remote_name>:<bucket_name>/<object_name>
Specify:
<command>— Rclone command likerclone <subcommand>. You can view all commands on the Rclone website or in the output of the commandrclone --help<remote_name>— connection name specified when configuring Rclone;<bucket_name>— bucket name;- optional:
<object_name>— object name.
Create a bucket
You can create only private buckets via the S3 API.
-
Open the CLI.
-
Create a bucket:
rclone mkdir <remote_name>:<bucket_name>Specify:
<remote_name>— connection name specified when configuring Rclone;<bucket_name>— name of the new bucket. Take into account bucket naming rules; for more information, see the Bucket naming rules guide in the AWS documentation.
View the object list
-
Open the CLI.
-
View the list of objects:
rclone ls <remote_name>:<bucket_name>/<prefix>Specify:
<remote_name>— connection name specified when configuring Rclone;<bucket_name>— bucket name;- optional:
<prefix>— prefix of the objects to display.
Upload an object
When performing copy and synchronization operations, Rclone checks all objects based on the date and time of modification or md5 sum. Objects that have been modified are transferred from the source directory to the destination directory.
-
Open the CLI.
-
Upload an object from the local directory:
rclone copy <path> <remote_name>:<bucket_name>/<object_name>Specify:
<path>— path to the object in the local directory;<remote_name>— connection name specified when configuring Rclone;<bucket_name>— bucket name;- optional:
<object_name>— name with which the object will be uploaded. If omitted, the file name will be used.
Get an object link
You can get a link to an object in a public or private bucket via a presigned URL. Learn more about presigned URLs in the Sharing objects with presigned URLs guide in the AWS documentation.
-
Open the CLI.
-
Get a link:
rclone link <remote_name>:<bucket_name>/<path_to_object> --expire <time>Specify:
<remote_name>— connection name specified when configuring Rclone;<bucket_name>— bucket name;<path_to_object>— path to the object in the bucket;- optional:
--expire <time>— validity period of the link, where<time>is the time after which the link will expire, for example24h. If you do not specify the--expire <time>parameter, the link will be valid for one hour.
Delete an object
-
Open the CLI.
-
Delete the object:
rclone deletefile <remote_name>:<bucket_name>/<object_name>Specify:
<remote_name>— connection name specified when configuring Rclone;<bucket_name>— bucket name;<object_name>— name of the object to delete.