Skip to main content

Rclone

Last update:

Rclone is a command-line interface for working with S3 objects.

Configure Rclone

  1. Configure S3 access.
  2. Install the client.
  3. Create an Rclone configuration.

1. Configure S3 access

Access can be configured by the Account Owner or a user with the iam.admin role.

  1. Create a service user with a role with S3 access. If you use a service user with the s3.user, object_storage_user, or s3.bucket.user role, an access policy must be configured for the bucket, and its rules must allow access to this user.
  2. Issue an S3 key to the user.

2. Install the client

For your information

For compatibility with Selectel, Rclone version v1.69 or higher is required.

  1. On the Rclone website, download the distribution for Windows.

  2. Unpack the distribution archive.

  3. Open the command prompt.

  4. Navigate to the directory containing the distribution:

    cd <path>

    Specify <path> — the path to the directory with the distribution.

3. Create an Rclone configuration

  1. Make sure that Virtual-Hosted addressing is enabled in the bucket.

  2. Open the configuration mode:

    rclone config

    A dialog will appear in the console:

    No remotes found, make a new one?
    n) New remote
    s) Set configuration password
    q) Quit config
  3. Create a new configuration:

    n/s/q> n
  4. Enter a name for the remote storage connection (for example, selectel_s3):

    name> selectel_s3
  5. Enter the storage type indicated after the line Amazon S3 Compliant Storage Providers including ..., Selectel, ...:

    Storage> s3
  6. Enter the provider type indicated after the line Any other S3 compatible provider:

    provider> Selectel
  7. Select the method for obtaining credentials indicated after the line Enter AWS credentials in the next step:

    env_auth> false
  8. Enter the AWS Access Key ID:

    access_key_id> <access_key>

    Specify <access_key> — the value of the Access key field from the S3 key.

  9. Enter the AWS Secret Access Key (password):

    secret_access_key> <secret_key>

    Specify <secret_key> — the value of the Secret key field from the S3 key.

  10. Enter the pool where S3 is located (e.g., ru-1):

    region> <pool>
  11. Enter the URL for S3 API access:

    endpoint> <s3_domain>

    Specify <s3_domain> — the S3 API domain. The domain depends on the pool in which S3 is located.

  12. Leave the location_constraint parameter empty.

  13. Leave the acl parameter empty.

  14. Leave the Edit advanced config parameter empty or enter n.

  15. Verify the configuration:

    Remote config
    --------------------
    [selectel_s3]
    type = s3
    provider = Selectel
    env_auth = false
    access_key_id = <access_key>
    secret_access_key = <secret_key>
    region = <pool>
    endpoint = <s3_domain>
    --------------------
    y) Yes this is OK
    e) Edit this remote
    d) Delete this remote

    If the configuration is correct, press Enter. If not, enter e and edit the configuration.

  16. Confirm the configuration creation:

    y/e/d> y
  17. 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> — an Rclone command in the format rclone <subcommand>. You can view all commands on the Rclone website or in the output of the rclone --help command
  • <remote_name> — the connection name specified when configuring Rclone;
  • <bucket_name> — the bucket name;
  • optional: <object_name> — the object name.

Create a bucket

You can create only private buckets via the S3 API.

  1. Open the CLI.

  2. Create a bucket:

    rclone mkdir <remote_name>:<bucket_name>

    Specify:

    • <remote_name> — the connection name specified when configuring Rclone;
    • <bucket_name> — the name of the new bucket. Consider the bucket naming rules; learn more in the Bucket naming rules section of the AWS documentation.

View the object list

  1. Open the CLI.

  2. View the list of objects:

    rclone ls <remote_name>:<bucket_name>/<prefix>

    Specify:

    • <remote_name> — the connection name specified when configuring Rclone;
    • <bucket_name> — the bucket name;
    • optional: <prefix>prefix to filter the objects by.

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.

  1. Open the CLI.

  2. Upload an object from the local directory:

    rclone copy <path> <remote_name>:<bucket_name>/<object_name>

    Specify:

    • <path> — the path to the object in the local directory;
    • <remote_name> — the connection name specified when configuring Rclone;
    • <bucket_name> — the bucket name;
    • optional: <object_name> — the name to be assigned to the uploaded object. If this is not specified, the filename will be used.

You can obtain a link to an object in a public or private bucket using a signed URL (Presigned URL). Learn more about Presigned URLs in the Sharing objects with presigned URLs section of the AWS documentation.

  1. Open the CLI.

  2. Get a link:

    rclone link <remote_name>:<bucket_name>/<path_to_object> --expire <time>

    Specify:

    • <remote_name> — the connection name specified when configuring Rclone;
    • <bucket_name> — the bucket name;
    • <path_to_object> — the path to the object in the bucket;
    • optional: --expire <time> — the link expiration time, where <time> is the time after which the link will stop working, e.g., 24h. If you do not add the --expire <time> parameter, the link will be valid for one hour.

Delete an object

  1. Open the CLI.

  2. Delete the object:

    rclone deletefile <remote_name>:<bucket_name>/<object_name>

    Specify:

    • <remote_name> — the connection name specified when configuring Rclone;
    • <bucket_name> — the bucket name;
    • <object_name> — the name of the object to delete.