public_notes/content/20240222192025 Raspi4 5でrcloneを使う.md

139 lines
4.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 20240222192025 Raspi4 5でrcloneを使いdropboxと同期
#rclone #raspi
## rclone何
色々なオンラインストレージと同期できるコマンドラインプログラム。
[Rclone](https://rclone.org/)
> Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors' web storage interfaces. [Over 70 cloud storage products](https://rclone.org/#providers) support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.
## インストール
20240407 `sudo apt install rclone` でインストールできた。下記で手動でやってもOK
goが必要かも。 [[20240205152229 raspi 4 5にgoをインストールする|raspi4にgoをインストールする]] を参照。
[Rclone downloads](https://rclone.org/downloads/) から、該当のものをダウンロードする。
Raspi4の場合、 ARM - 64 Bit。 Raspberry Pi OS の場合は.debが該当。
こんな感じ。バージョンなどは適宜読みかえる。
```
$ wget https://downloads.rclone.org/v1.65.2/rclone-v1.65.2-linux-arm64.deb
wget https://downloads.rclone.org/v1.65.2/rclone-v1.65.2-linux-arm64.deb
--2024-02-22 19:17:52-- https://downloads.rclone.org/v1.65.2/rclone-v1.65.2-linux-arm64.deb
Resolving downloads.rclone.org (downloads.rclone.org)... 2a01:4f9:c012:7154::1, 95.217.6.16
Connecting to downloads.rclone.org (downloads.rclone.org)|2a01:4f9:c012:7154::1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19388190 (18M) [application/vnd.debian.binary-package]
Saving to: rclone-v1.65.2-linux-arm64.deb
rclone-v1.65.2-linux-a 100%[===========================>] 18.49M 4.89MB/s in 3.8s
2024-02-22 19:17:57 (4.89 MB/s) - rclone-v1.65.2-linux-arm64.deb saved [19388190/19388190]
$ sudo dpkg -i rclone-v1.65.2-linux-arm64.deb
Selecting previously unselected package rclone.
(Reading database ... 114658 files and directories currently installed.)
Preparing to unpack rclone-v1.65.2-linux-arm64.deb ...
Unpacking rclone (1.65.2) ...
Setting up rclone (1.65.2) ...
Processing triggers for man-db (2.11.2-2) ...
```
## 設定
[Dropbox](https://rclone.org/dropbox/) に書いてある通りにやる。・・・が、CUIにsshアクセスしていて、ブラウザが起動できないので、リモートで設定とauthなどをして、それを貼りつける必要がある。
```
[ここはwindows上のwsl2でやった。windowsやmacでも可能。]
$ rclone authorize "dropbox"
2024/02/22 19:38:27 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=***
[ここで上記URLにアクセス。ローカルホストからでないと接続が拒否されるので注意。wslg+firefoxなどが設定してある必要がある。許可ボタンを押す。]
2024/02/22 19:38:27 NOTICE: Log in and authorize rclone for access
2024/02/22 19:38:27 NOTICE: Waiting for code...
2024/02/22 19:38:51 NOTICE: Got code
Paste the following into your remote machine --->
.....
<---End paste
```
などと表示されるので、 ... をコピー。
```
$ rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
Enter name for new remote.
name> remote
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
.
.
.
13 / Dropbox
\ (dropbox)
Storage> [13]
client_id> [ENTER]
client_secret> [ENTER]
Edit advanced config?
y) Yes
n) No (default)
y/n> n [ENTER]
Use web browser to automatically authenticate rclone with remote?
* Say Y if the machine running rclone has a web browser you can use
* Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes (default)
n) No
y/n> n [ENTER]
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "dropbox"
Then paste the result.
Enter a value.
config_token> [コピーした内容をペースト]
Configuration complete.
Options:
- type: dropbox
- token: {"****"}
Keep this "remote" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> [y]
Current remotes:
Name Type
==== ====
remote dropbox
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> [q]
```
ここまでで設定できている。
```
$ rclone lsd remote:
```
などと打ってみて、それらしきリストが表示されればOK。 `remote:` のように、接続先には : がつくので注意。 scpとかと同じ感じ。