Rclone command collection: start synchronous copy download copy file parameter usage method

Rclone It is a command-line tool that supports synchronizing, uploading and downloading data between different object storages and network disks.

And, with some settings, you can easily implement very practical functions such as offline download and VPS server backup.

This article will share the command parameters commonly used by Rclone.

Rclone command collection: start synchronous copy download copy file parameter usage method

Install Rclone

Linux/CentOS/macOS/BSD

Rclone officially provides a one-click installation script:

curl https://rclone.org/install.sh | sudo bash

Windows

Click the link below to enter the Rclone download page ▼

  • Then, select Windows Downloads.

Rclone installation configuration setup command

rclone config – Enter the interactive configuration option to perform operations such as adding, deleting, and managing network disks.

For details, see the following Rclone installation and configuration tutorial▼

rclone config file – Display the path of the configuration file, the general configuration file is in ~/.config/rclone/rclone.conf

rclone config show – Show profile information

Rclone upgrade update version command

Enter the following command to upgrade and update the Rclone version▼

rclone selfupdate
  • Note that this command is not available prior to rclone version 1.55.
  • If a failure message appears:unknown command "selfupdate", you need to follow this installation instruction tutorial to install and update manually ▼

How to uninstall remove RClone?

To uninstall and remove the rclone configuration file, use the following command to list the current RClone configuration path▼

rclone config file

This will list the path to the current configuration file.Then you can delete the path location according to the example below.This will delete the credentials for the remote storage service.

Rclone uninstall command

noticeAfter deleting Rclone with the following command, you will no longer be able to access remote storage services and will need to recreate them▼

sudo rm /home/pi/.config/rclone/rclone.conf

To remove rclone commands and man pages, just follow the command below to remove the files▼

sudo rm /usr/bin/rclone
sudo rm /usr/local/share/man/man1/rclone.1

Rclone download command syntax

# 本地到网盘
rclone [功能选项] <本地路径> <网盘名称:路径> [参数] [参数] ...

# 网盘到本地
rclone [功能选项] <网盘名称:路径> <本地路径> [参数] [参数] ...

# 网盘到网盘
rclone [功能选项] <网盘名称:路径> <网盘名称:路径> [参数] [参数] ...

Rclone usage example

rclone move -v /Download Onedrive:/Download --transfers=1

Rclone command common function options

  • rclone copy – copy files
  • rclone move – to move the files, if you want to delete the empty source directory after the move, add --delete-empty-src-dirs 参数
  • rclone sync – Sync files: Synchronize the source directory to the target directory and files, only the target directory and files are changed.
  • rclone size – Check the file size of the network disk.
  • rclone delete – Delete the file content under the path.
  • rclone purge – Deletes the path and all its file contents.
  • rclone mkdir - Create a directory.
  • rclone rmdir – Delete a directory.
  • rclone rmdirs – Delete the empty directory under the specified spiritual environment.if add --leave-root parameter, the root directory will not be deleted.
  • rclone check – Check that the source and destination address data match.
  • rclone ls – List all files in the specified path with their size and path.
  • rclone lsl – One more display upload time than above.
  • rclone lsd List the directories under the specified path.
  • rclone lsf – List the directories and files under the specified path.

How to use the Rclone parameter command

  • -n = --dry-run – Test run, to see what operations rclone will perform in actual operation.
  • -P = --progress – Display real-time transmission progress, refresh once every 500mS, otherwise refresh once every minute by default.
  • --cache-chunk-size SizeSuffi – The block size, the default is 5M, in theory, the larger the upload speed, the more memory it takes up.If set too large, it may cause the process to break.
  • --cache-chunk-total-size SizeSuffix – The total size that a block can occupy on the local disk, default 10G.
  • --transfers=N – Number of parallel files, default is 4.It is recommended to reduce this parameter on a VPS with relatively small memory, for example: on a small VPS with 128M, it is recommended to set it to 1.
  • --config string – specify the configuration file path,stringis the configuration file path.
  • --ignore-errors – Skip errors.For example, OneDrive will prompt after uploading some special filesFailed to copy: failed to open source object: malwareDetected: Malware detected, which will cause subsequent transmission tasks to be terminated, and this parameter can be added to skip errors.But it should be noted that the exit status code of RCLONE will not be0.

Of course, the role of rclone is much more than that, and some commonly used Rclone commands are listed below.

Rclone copy file copy command

Copy ▼

rclone copy

move ▼

rclone move

delete ▼

rclone delete

Rclone sync command

Sync ▼

rclone sync

Additional parameters: display real-time speed ▼

-p

Additional parameters: limit speed 40MB ▼

--bwlimit 40M

Additional parameter: number of parallel files ▼

--transfers=N

Rclone start command

start rclone ▼

systemctl start rclone

stop rclone ▼

systemctl stop rclone

View rclone status ▼

systemctl status rclone

View Profile Location ▼

rclone config file

Rclone log

rclone has 4 levels of logging,ERROR.NOTICE.INFO  DEBUG.By default, rclone will generate ERROR  NOTICE level message.

  • -q – rclone will only generate ERROR News.
  • -v -- rclone will generate ERROR.NOTICE  INFO news,recommend this.
  • -vv – rclone will generate ERROR.NOTICE.INFO DEBUG News.
  • --log-level LEVEL The – flag controls the log level.

Rclone output log to file command

使用 --log-file=FILE option, rclone will Error.Info  Debug message and standard error redirected to FILE,here FILE is the log file path you specified.

Another way is to use the system's pointing command, such as:

rclone sync -v Onedrive:/DRIVEX Gdrive:/DRIVEX > "~/DRIVEX.log" 2>&1

Rclone filter, include and exclude parameters

--exclude – Exclude files or directories.

--include – Include a file or directory.

--filter – File filtering rules, equivalent to other usage methods of the above two options.Include rules starting with + starts with exclusion rules starting with - beginning.

Rclone file type filter parameter

such as --exclude "*.bak",--filter "- *.bak", exclude all bak document.Can also write.

such as --include "*.{png,jpg}",--filter "+ *.{png,jpg}", including all png  jpg files, excluding other files.

--delete-excluded Delete excluded files.It needs to be used in conjunction with the filter parameter, otherwise it is invalid.

Rclone directory filter parameters

Directory filtering needs to be added after the directory name /, otherwise it will be treated as a file for matching.by / At the beginning, it will only match the root directory (under the specified directory), otherwise it will match the entire directory.The same applies to files.

--exclude ".git/" exclude all directories.git table of Contents.

--exclude "/.git/" Exclude only the root directory.git table of Contents.

--exclude "{Video,Software}/" exclude all directories Video  Software table of Contents.

--exclude "/{Video,Software}/" Exclude only the root directory Video  Software table of Contents.

--include "/{Video,Software}/**" Include only the root directory Video  Software all contents of the directory.

Rclone file size filter parameters

The default size unit is kBytes , but you can use k .M Or G suffix.

--min-size Filter files smaller than the specified size.for example --min-size 50 Indicates that files smaller than 50k will not be transferred.

--max-size Filter files larger than the specified size.for example --max-size 1G Indicates that files larger than 1G will not be transferred.

noticeIn actual test use, it is found that the two options of size filtering cannot be used at the same time.

Rclone filter rule file parameters

--filter-from <规则文件> Add include/exclude rules from files.for example --filter-from filter-file.txt.

Rclone filter rule file example:

- secret*.jpg
+ *.jpg
+ *.png
+ file2.avi
- /dir/Trash/**
+ /dir/**
- *

Below are examples of more common and simple filter usages, for more complex and high-end usages, check outRclone official filter rules document.

Rclone time or duration options

The TIME or DURATION option can be specified as a duration string or a time string.

A duration string may be a sequence of signed decimal numbers, each with an optional decimal and unit suffix, such as "300ms", "-1.5h", or "2h45m".The default unit is seconds or the following abbreviations are valid:

  • ms– milliseconds
  • s - second
  • m - minute
  • h - Hour
  • d - sky
  • w - week
  • M – several months
  • y - year

These can also be specified as absolute times in the following formats:

  • RFC3339 - eg2006-01-02T15:04:05ZOr2006-01-02T15:04:05+07:00
  • ISO8601 date and time, local time zone –2006-01-02T15:04:05
  • ISO8601 date and time, local time zone –2006-01-02 15:04:05
  • ISO8601 date – 2006-01-02(YYYY-MM-DD)

Rclone environment variables

Every option in rclone can be set via environment variables.The name of the environment variable can be specified bylong option nameconvert, delete -- prefix, change - for_, capitalized and prefixed RCLONE_.The priority of environment variables will be lower than that of command-line options, that is, when the corresponding options are appended through the command line, the values ​​set by the environment variables will be overwritten.

For example, setting the minimum upload size --min-size 50, using the environment variable is RCLONE_MIN_SIZE=50.When the environment variable is set, in the command line use --min-size 100, then the value of the environment variable will be overwritten.

Rclone common environment variables

  • RCLONE_CONFIG – Custom configuration file path
  • RCLONE_CONFIG_PASS – If rclone is encrypted, set this environment variable as a password to automatically decrypt the configuration file.
  • RCLONE_RETRIES – Upload failure retry times, default 3 times
  • RCLONE_RETRIES_SLEEP – Upload failure retry waiting time, disabled by default, units,m,hRepresent seconds, minutes, and hours, respectively.
  • CLONE_TRANSFERS – Number of files uploaded in parallel.
  • RCLONE_CACHE_CHUNK_SIZE – The block size, the default is 5M, in theory, the larger the upload speed, the more memory it takes up.If set too large, it may cause the process to break.
  • RCLONE_CACHE_CHUNK_TOTAL_SIZE – The total size that a block can occupy on the local disk, default 10G.
  • RCLONE_IGNORE_ERRORS=true – Skip errors.

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top