ユーザ用ツール

サイト用ツール


サイドバー

このページの翻訳:



最近の更新



Tag Cloud

50_dialy:2024:10:02

2024.10.02 rclone

rclone で、s3にフォルダごとアップロードしたり、mountしたりできる

rcloneインストール

apt install rclone

rclone config

rcloneのconfigコマンドで、設定ファイルを作成する。

# rclone config
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

name> s3

 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, Tencent COS, etc)
   \ "s3"
Storage> 4

13 / Any other S3 compatible provider
   \ "Other
provider> 13

 1 / Enter AWS credentials in the next step
   \ "false"
env_auth> 1

AWS Access Key ID.
Leave blank for anonymous access or runtime credentials.
Enter a string value. Press Enter for the default ("").
access_key_id> fbXXXXXXXXXXXXXX7QF

AWS Secret Access Key (password)
Leave blank for anonymous access or runtime credentials.
Enter a string value. Press Enter for the default ("").
secret_access_key> auVaS6XXXXXXXXXXXXXXXXXXXXXXXXXXXXdrH6z


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://s33.kumolabo.com

Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n

[s3]
provider = Other
env_auth = false
access_key_id = fbXXXXXXXXXXXXXX7QF
secret_access_key = auVaS6XXXXXXXXXXXXXXXXXXXXXXXXXXXXdrH6z
endpoint = https://s3.fl8.com
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

configファイルの場所

「~/.config/rclone/rclone.conf 」にファイルができます。
普通に下記を直接作成してもOK

# cat ~/.config/rclone/rclone.conf 
[s3]
type = s3
provider = Other
env_auth = false
access_key_id = fbXXXXXXXXXXXXXX7QF
secret_access_key = auVaS6XXXXXXXXXXXXXXXXXXXXXXXXXXXXdrH6z
endpoint = https://s3.fl8.com

configファイルを指定

–configでconfigファイルを指定も可能

rclone --config /path/to/custom/rclone.conf ls s3:mybucket

rcloneコマンド

ls

対象バケットのファイル一覧を表示

rclone ls s3:mybucket
        4 a.txt
        4 b.txt
        4 c.txt

copy

rclone copy a.txt s3:mybucket

sync

ローカルフォルダと、S3側のフォルダと同期させる。
※もしローカル側でファイル削除されていたら、S3側も削除される。

# tree work/
work/
├── a.txt
├── b.txt
└── c.txt
# rclone sync work s3:mybucket/work

# rclone ls s3:mybucket
        5 work/a.txt
        8 work/b.txt
       18 work/c.txt

# rm work/b.txt

# rclone sync work s3:mybucket/work
# rclone ls s3:matsui
        5 work/a.txt
       18 work/c.txt

progress

–progressで進捗を表示

# rclone sync --progress /app/dokuwiki s3:mybucket/dokuwiki
Transferred:   	   48.249M / 161.204 MBytes, 30%, 672.532 kBytes/s, ETA 2m51s
Checks:              8205 / 8205, 100%
Transferred:         4627 / 14639, 32%
Elapsed time:      1m13.6s
Transferring:
 * data/dokuwiki/data/cac…8539742999e855252.feed:100% /2.129k, 0/s, -
 * data/dokuwiki/data/cac…aaeee960c650ad936378.i:100% /1.263k, 0/s, -
 * data/dokuwiki/data/cac…0c650ad936378.metadata:100% /10, 0/s, -
 * data/dokuwiki/data/cac…e960c650ad936378.xhtml:100% /401, 0/s, -

mount

S3フォルダをローカルにマウントする。

rclone mount s3:mybucket /mnt/ --daemon
# df 
Filesystem                       1K-blocks     Used     Available Use% Mounted on
s3:mybucket                    1099511627776        0 1099511627776   0% /mnt
50_dialy/2024/10/02.txt · 最終更新: 2024/10/02 22:49 by matsui