天天看點

Rclone使用教程 - 挂載Onedrive和谷歌網盤

1. 介紹

Rclone 是一個用于多個雲平台之間同步檔案和目錄的指令行工具,其支援多種營運商網盤。

  • 官網網址:https://rclone.org
  • 開源位址:https://github.com/ncw/rclone

2. 安裝與配置

2.1 下載下傳安裝rclone

  1. windows版本:下載下傳rclone并解壓
  2. Linux版本:
    curl https://rclone.org/install.sh | sudo bash
               

2.2 配置OneDrive

  1. 在目錄下打開cmd運作指令

    rclone authorize "onedrive"

    世紀互聯運作的指令

    rclone authorize onedrive "應用程式(用戶端)ID" "用戶端密碼值" --onedrive-is-21vianet-version=true

  2. 複制授權碼:

    {"access_token":"xxxx"}

    Rclone使用教程 - 挂載Onedrive和谷歌網盤
  3. 配置
    rclone config
               
    設定步驟如下:
    root@localhost:~# rclone config
    No remotes found - make a new one
    n) New remote
    s) Set configuration password
    q) Quit config
    n/s/q> n  #建立一個挂載
    name> onedrive  #設定挂載的名稱onedrive
    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 / 1Fichier
       \ "fichier"
     2 / Alias for an existing remote
       \ "alias"
     3 / Amazon Drive
       \ "amazon cloud drive"
     4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
       \ "s3"
     5 / Backblaze B2
       \ "b2"
     6 / Box
       \ "box"
     7 / Cache a remote
       \ "cache"
     8 / Citrix Sharefile
       \ "sharefile"
     9 / Dropbox
       \ "dropbox"
    10 / Encrypt/Decrypt a remote
       \ "crypt"
    11 / FTP Connection
       \ "ftp"
    12 / Google Cloud Storage (this is not Google Drive)
       \ "google cloud storage"
    13 / Google Drive
       \ "drive"
    14 / Google Photos
       \ "google photos"
    15 / Hubic
       \ "hubic"
    16 / In memory object storage system.
       \ "memory"
    17 / Jottacloud
       \ "jottacloud"
    18 / Koofr
       \ "koofr"
    19 / Local Disk
       \ "local"
    20 / Mail.ru Cloud
       \ "mailru"
    21 / Mega
       \ "mega"
    22 / Microsoft Azure Blob Storage
       \ "azureblob"
    23 / Microsoft OneDrive
       \ "onedrive"
    24 / OpenDrive
       \ "opendrive"
    25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
       \ "swift"
    26 / Pcloud
       \ "pcloud"
    27 / Put.io
       \ "putio"
    28 / QingCloud Object Storage
       \ "qingstor"
    29 / SSH/SFTP Connection
       \ "sftp"
    30 / Sugarsync
       \ "sugarsync"
    31 / Tardigrade Decentralized Cloud Storage
       \ "tardigrade"
    32 / Transparently chunk/split large files
       \ "chunker"
    33 / Union merges the contents of several upstream fs
       \ "union"
    34 / Webdav
       \ "webdav"
    35 / Yandex Disk
       \ "yandex"
    36 / http Connection
       \ "http"
    37 / premiumize.me
       \ "premiumizeme"
    38 / seafile
       \ "seafile"
    Storage> 23  #選擇第23項的onedrive
    ** See help for onedrive backend at: https://rclone.org/onedrive/ **
    
    Microsoft App Client Id
    Leave blank normally.
    Enter a string value. Press Enter for the default ("").
    client_id>   #跳過
    Microsoft 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>  #跳過
    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  #選擇n
    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 "onedrive"
    
    Then paste the result below:
    result> {"access_token":"xxxxxxxx"}  #輸入授權碼
    Choose a number from below, or type in an existing value
     1 / OneDrive Personal or Business
       \ "onedrive"
     2 / Root Sharepoint site
       \ "sharepoint"
     3 / Type in driveID
       \ "driveid"
     4 / Type in SiteID
       \ "siteid"
     5 / Search a Sharepoint site
       \ "search"
    Your choice> 1   #選擇1,onedrive
    Found 1 drives, please select the one you want to use:
    0:  (personal) id=xxxxxxxx
    Chose drive to use:> 0  #選擇挂載的onedrive網盤
    Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=xxxxxxxx
    Is that okay?
    y) Yes (default)
    n) No
    y/n>  #跳過
    --------------------
    [myone]
    type = onedrive
    token = {"access_token":"xxxxxxxx"}
    drive_id = xxxxxx
    drive_type = personal
    --------------------
    y) Yes this is OK (default)
    e) Edit this remote
    d) Delete this remote
    y/e/d> y  #跳過
    Current remotes:
    
    Name                 Type
    ====                 ====
    onedrive                onedrive
    
    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> 
               

2.3 配置谷歌網盤

運作指令:

rclone config
           
$ ./rclone.exe config
Current remotes:

Name                 Type
====                 ====
onedrive             onedrive

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> n #建立
name> 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 / 1Fichier
   \ "fichier"
 2 / Alias for an existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS,
 Minio, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Dropbox
   \ "dropbox"
10 / Encrypt/Decrypt a remote
   \ "crypt"
11 / FTP Connection
   \ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
15 / Hubic
   \ "hubic"
16 / In memory object storage system.
   \ "memory"
17 / Jottacloud
   \ "jottacloud"
18 / Koofr
   \ "koofr"
19 / Local Disk
   \ "local"
20 / Mail.ru Cloud
   \ "mailru"
21 / Mega
   \ "mega"
22 / Microsoft Azure Blob Storage
   \ "azureblob"
23 / Microsoft OneDrive
   \ "onedrive"
24 / OpenDrive
   \ "opendrive"
25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
26 / Pcloud
   \ "pcloud"
27 / Put.io
   \ "putio"
28 / QingCloud Object Storage
   \ "qingstor"
29 / SSH/SFTP Connection
   \ "sftp"
30 / Sugarsync
   \ "sugarsync"
31 / Tardigrade Decentralized Cloud Storage
   \ "tardigrade"
32 / Transparently chunk/split large files
   \ "chunker"
33 / Union merges the contents of several upstream fs
   \ "union"
34 / Webdav
   \ "webdav"
35 / Yandex Disk
   \ "yandex"
36 / http Connection
   \ "http"
37 / premiumize.me
   \ "premiumizeme"
38 / seafile
   \ "seafile"
Storage>     13  #第13選谷歌網盤
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id>
Google Application Client Secret
Setting your own is recommended.
Enter a string value. Press Enter for the default ("").
client_secret>
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), or for rclone to use
a non root folder as its starting point.

Enter a string value. Press Enter for the default ("").
root_folder_id>
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>
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n>   #跳過
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>  #跳過
           

2.4 擷取配置檔案

搜尋 ,windows下正常都在

C:\Users\你的使用者名\\.config\rclone

目錄下,Linux正常都在

./.config/rclone/

目錄下

3. 使用教程

常用指令:

rclone config - 以控制會話的形式添加rclone的配置,配置儲存在.rclone.conf檔案中。
rclone copy - 将檔案從源複制到目的位址,跳過已複制完成的。
rclone sync - 将源資料同步到目的位址,隻更新目的位址的資料。
rclone move - 将源資料移動到目的位址。
rclone delete - 删除指定路徑下的檔案内容。
rclone purge - 清空指定路徑下所有檔案資料。
rclone mkdir - 建立一個新目錄。
rclone rmdir - 删除空目錄。
rclone check - 檢查源和目的位址資料是否比對。
rclone ls - 列出指定路徑下所有的檔案以及檔案大小和路徑。
rclone lsd - 列出指定路徑下所有的目錄/容器/桶。
rclone lsl - 列出指定路徑下所有檔案以及修改時間、檔案大小和路徑。
rclone md5sum - 為指定路徑下的所有檔案産生一個md5sum檔案。
rclone sha1sum - 為指定路徑下的所有檔案産生一個sha1sum檔案。
rclone size - 擷取指定路徑下,檔案内容的總大小。.
rclone version - 檢視目前版本。
rclone cleanup - 清空remote。
rclone dedupe - 互動式查找重複檔案,進行删除/重命名操作。
           
  1. 顯示網盤上的目錄
    rclone lsd onedrive:   #onedrive是上面設定的名稱
    rclone lsd gdrive:    #gdrive是上面設定的名稱
               
  2. 拷貝谷歌網盤上的檔案到Onedrive
    !rclone copy gdrive:music onedrive:音樂 --ignore-existing --config ./music/rclone.conf 
    # --config xxxx.conf 表示指定配置檔案
    # --ignore-existing表示跳過已存在的檔案
    # 此指令表示将谷歌網盤下的music目錄複制到Onedrive網盤下的音樂目錄
               
  3. 挂在Onedrive
    rclone mount onedrive:音樂 music --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --config /content/gdrive/My\ Drive/music/rclone.conf
               

4. Linux上挂載網盤

  1. 建立Linux下的檔案夾
    rm -rf /root/music  #删除已有的目錄
    mkdir /root/music  #建立目錄
               
  2. 挂載磁盤

    下載下傳腳本

    wget -N --no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/rcloned
               
    使用

    vim rcloned

    修改腳本項
    NAME="myone" #建立的rclone名,本文此處填ojbk
    REMOTE="音樂" #遠端挂載位址對應的檔案夾,是你OneDrive對應的具體目錄
    LOCAL="/root/music" #在本機上的挂載位址
               
    啟動腳本

    rcloned start

  3. 挂載成功後,輸入

    df -h

    指令檢視
    Rclone使用教程 - 挂載Onedrive和谷歌網盤
  4. 設定開機啟動
    mv rcloned /etc/init.d/rcloned    #移動rcloned到init(開機啟動目錄)下
    chmod +x /etc/init.d/rcloned      #給rcloned可執行權限
    chkconfig rcloned on                   #設定自啟動
    bash /etc/init.d/rcloned start       #啟動rclone
               

繼續閱讀