由于 cloudflare R2 的web 页面只能上传100个文件,之前Wordpress 的文件需要批量上传,这里采用 rclone 进行批量上传。

安装 rclone

1
2
3
4
brew install rclone
rclone config
vi /Users/brty.liu/.config/rclone/rclone.conf
rclone tree cloudfr2pic
image-20240404201346551

api key 信息根据如上填写:

1
2
3
4
5
6
7
8
cat .config/rclone/rclone.conf
[adminr2]
type = s3
provider = Cloudflare
access_key_id = a69ac6916xxxxxxxx
secret_access_key = 8f16be8xxxxxx
endpoint = https://xxxxx57d2.r2.cloudflarestorage.com
acl = private

列出信息

1
2
3
4
5
6
7
8
9
10
11
rclone tree adminr2:wp-content
/
└── uploads
├── 2
├── 2014
│ └── 04
│ ├── 6876385555_74a0d7d7ee_b-1024x270.jpg
│ ├── 6876385555_74a0d7d7ee_b-1024x445.jpg
│ ├── 6876385555_74a0d7d7ee_b-1024x683.jpg
│ ├── 6876385555_74a0d7d7ee_b-120x120.jpg
│ ├── 6876385555_74a0d7d7ee_b-150x150.jpg
1
2
3
4
5
6
7
8
9
10
rclone tree adminr2:wp-content
rclone copy 2017 adminr2:wp-content/uploads/
rclone mkdir adminr2:wp-content/uploads/2017
rclone mkdir adminr2:wp-content/uploads/
rclone purge adminr2:wp-content/uploads/06
rclone purge adminr2:wp-content/uploads/08
rclone purge adminr2:wp-content/uploads/09
rclone copy 2017 adminr2:wp-content/uploads/2017/
rclone copy 2018 adminr2:wp-content/uploads/2018/
rclone copy 2019 adminr2:wp-content/uploads/2019/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 rclone --help

Rclone syncs files to and from cloud storage providers as well as
mounting them, listing them in lots of different ways.

See the home page (https://rclone.org/) for installation, usage,
documentation, changelog and configuration walkthroughs.

Usage:
rclone [flags]
rclone [command]

Available Commands:
about Get quota information from the remote.
authorize Remote authorization.
backend Run a backend-specific command.
bisync Perform bidirectional synchronization between two paths.
cat Concatenates any files and sends them to stdout.
check Checks the files in the source and destination match.
checksum Checks the files in the source against a SUM file.
cleanup Clean up the remote if possible.
completion Output completion script for a given shell.
config Enter an interactive configuration session.
copy Copy files from source to dest, skipping identical files.
copyto Copy files from source to dest, skipping identical files.
copyurl Copy url content to dest.
cryptcheck Cryptcheck checks the integrity of an encrypted remote.
cryptdecode Cryptdecode returns unencrypted file names.
dedupe Interactively find duplicate filenames and delete/rename them.
delete Remove the files in path.
deletefile Remove a single file from remote.
gendocs Output markdown docs for rclone to the directory supplied.
hashsum Produces a hashsum file for all the objects in the path.
help Show help for rclone commands, flags and backends.
link Generate public link to file/folder.
listremotes List all the remotes in the config file and defined in environment variables.
ls List the objects in the path with size and path.
lsd List all directories/containers/buckets in the path.
lsf List directories and objects in remote:path formatted for parsing.
lsjson List directories and objects in the path in JSON format.
lsl List the objects in path with modification time, size and path.
md5sum Produces an md5sum file for all the objects in the path.
mkdir Make the path if it doesn't already exist.
mount Mount the remote as file system on a mountpoint.
move Move files from source to dest.
moveto Move file or directory from source to dest.
ncdu Explore a remote with a text based user interface.
obscure Obscure password for use in the rclone config file.
purge Remove the path and all of its contents.
rc Run a command against a running rclone.
rcat Copies standard input to file on remote.
rcd Run rclone listening to remote control commands only.
rmdir Remove the empty directory at path.
rmdirs Remove empty directories under the path.
selfupdate Update the rclone binary.
serve Serve a remote over a protocol.
settier Changes storage class/tier of objects in remote.
sha1sum Produces an sha1sum file for all the objects in the path.
size Prints the total size and number of objects in remote:path.
sync Make source and dest identical, modifying destination only.
test Run a test command
touch Create new file or change file modification time.
tree List the contents of the remote in a tree like fashion.
version Show the version number.

Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.

原文作者: liups.com

原文链接: http://liups.com/posts/rcloner2/

许可协议: 知识共享署名-非商业性使用 4.0 国际许可协议