(2020-08-17 初稿 - 2021-05-14 転記・修正)
はじめに
Dropboxが無料では3台のPCしか接続できなくなったので、オンラインストレージの活用方法を検討した結果、rcloneという筆者好みのコマンドラインインターフェース(CLI)のコマンドを見つけた。
ここでは、rcloneのインストール、GoogleDriveとDropboxへの接続設定、簡単な使い方について記述する。
インストール
インストールは、Debianのパッケージになっているので、以下のように簡単できる。
sudo apt install rclone
Google Driveの設定
Google Driveの設定ファイルを作成するが、以下のページを参考にした。多謝 m(__)m
$ rclone config 2020/07/21 19:17:41 NOTICE: Config file "/home/hoge/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config n/s/q> n #<= n を入力 name> gdrive #<= gdriveと入力(好きな名前を) Type of storage to configure. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / A stackable unification remote, which can appear to merge the contents of several remotes \ "union" 2 / Alias for a existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio) \ "s3" 5 / Backblaze B2 \ "b2" 6 / Box \ "box" 7 / Cache a remote \ "cache" 8 / Dropbox \ "dropbox" 9 / Encrypt/Decrypt a remote \ "crypt" 10 / FTP Connection \ "ftp" 11 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 12 / Google Drive \ "drive" 13 / Hubic \ "hubic" 14 / JottaCloud \ "jottacloud" 15 / Local Disk \ "local" 16 / Microsoft Azure Blob Storage \ "azureblob" 17 / Microsoft OneDrive \ "onedrive" 18 / OpenDrive \ "opendrive" 19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 20 / Pcloud \ "pcloud" 21 / SSH/SFTP Connection \ "sftp" 22 / Webdav \ "webdav" 23 / Yandex Disk \ "yandex" 24 / http Connection \ "http" Storage> 12 #<= 12を入力 ** See help for drive backend at: https://rclone.org/drive/ ** Google Application Client Id Leave blank normally. Enter a string value. Press Enter for the default (""). client_id> #<= Enterのみ Google Application Client Secret Leave blank normally. Enter a string value. Press Enter for the default (""). client_secret> #<= Enterのみ Scope that rclone should use when requesting access from drive. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Full access all files, excluding Application Data Folder. \ "drive" 2 / Read-only access to file metadata and file contents. \ "drive.readonly" / Access to files created by rclone only. 3 | These are visible in the drive website. | File authorization is revoked when the user deauthorizes the app. \ "drive.file" / Allows read and write access to the Application Data folder. 4 | This is not visible in the drive website. \ "drive.appfolder" / Allows read-only access to file metadata but 5 | does not allow any access to read or download file content. \ "drive.metadata.readonly" scope> 1 #<= 1を入力 ID of the root folder Leave blank normally. Fill in to access "Computers" folders. (see docs). Enter a string value. Press Enter for the default (""). root_folder_id> #<= Enterのみ Service Account Credentials JSON file path Leave blank normally. Needed only if you want use SA instead of interactive login. Enter a string value. Press Enter for the default (""). service_account_file> #<= Enterのみ Edit advanced config? (y/n) y) Yes n) No y/n> n #<= nを入力 Remote config Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine or Y didn't work y) Yes n) No y/n> n #<= nを入力 If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?(以下省略) Log in and authorize rclone for access Enter verification code> (ブラウザに表示されるcodeを入力) Configure this as a team drive? y) Yes n) No y/n> n #<= nを入力 -------------------- [gdrive] scope = drive token = {"access_token":(省略)} -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y #<= yを入力 Current remotes: Name Type ==== ==== gdrive drive 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 #<= qを入力
少々長いが、以上でGoogle Driveの設定は終了。
Dropboxの設定
続いて、Dropboxの設定は、以下のサイトを参考に行った。多謝 m(__)m
$ rclone config 2020/07/25 17:27:55 NOTICE: Config file "xxxxxxx/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config n/s/q> n name> dropbox <== 名前は dropbox としました。 Type of storage to configure. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / A stackable unification remote, which can appear to merge the contents of several remotes \ "union" 2 / Alias for a existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio) \ "s3" 5 / Backblaze B2 \ "b2" 6 / Box \ "box" 7 / Cache a remote \ "cache" 8 / Dropbox \ "dropbox" 9 / Encrypt/Decrypt a remote \ "crypt" 10 / FTP Connection \ "ftp" 11 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 12 / Google Drive \ "drive" 13 / Hubic \ "hubic" 14 / JottaCloud \ "jottacloud" 15 / Local Disk \ "local" 16 / Microsoft Azure Blob Storage \ "azureblob" 17 / Microsoft OneDrive \ "onedrive" 18 / OpenDrive \ "opendrive" 19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 20 / Pcloud \ "pcloud" 21 / SSH/SFTP Connection \ "sftp" 22 / Webdav \ "webdav" 23 / Yandex Disk \ "yandex" 24 / http Connection \ "http" Storage> 8 ** See help for dropbox backend at: https://rclone.org/dropbox/ ** Dropbox App Client Id Leave blank normally. Enter a string value. Press Enter for the default (""). client_id> ここはブランクのままエンター Dropbox App Client Secret Leave blank normally. Enter a string value. Press Enter for the default (""). client_secret> ここもブランクのままエンター Edit advanced config? (y/n) y) Yes n) No (default) y/n> n No を選択 Remote config Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes (default) n) No y/n> n CUIしか使えないので Noを選択 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 below: result> hoge@pad:~$ rclone authorize "dropbox" If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth Log in and authorize rclone for access Waiting for code... Got code Paste the following into your remote machine ---> {"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"} <---End pastehoge
ちなみに、Dropboxの場合、アプリを介しての接続が3台までで、ブラウザ経由またはrcloneで『Dropbox』を開く場合は、3台までという制限はない。
簡単な使い方
ファイルの一覧の表示
$ rclone ls gdrive: $ rclone ls dropbox:
ファイルのコピー
$ rclone copy rclone.txt gdrive: $ rclone copy gdrive:text.txt .
ファイルの同期
rclone sync で同期できるが、リモート側のファイルをいきなり削除する可能性があるので、--dry-run オプションを付けてテスト実行した後、実行した方が良い。
$ rclone sync source:path dest:path --dry-run # テスト実行 $ rclone sync source:path dest:path
おわりに
rcloneは、ファイルの更新等に応じて自動的に同期やコピーを行ってくれない点は、い面倒であるが、rcloneひとつで複数のネットワークデータサービスを活用できる点は、とても便利だ。
特にDropboxは無料で最大3台までの制限があるため、3台より多いPC間のデータ共有には、かなり威力を発揮すると思われる。
また、何かわかったら追記する。