介紹
google drive 需要大量的複製備份到另一個雲端硬碟,例如有 A:Team Drive(共享雲端硬碟)複製到 B:Team Drive(共享雲端硬碟),使用 Autorclone 及 gclone 工具,以本機 Windows 10 做為測試,如果是中國大陸使用者需要掛 VPN,此教學即使不董程式也可以學會 Auto rclone + gclone 安裝及設定。
-
名詞
- Team Drive = 共享雲端硬碟 = 團隊盤
- Autorclone(在新分頁開啟):利用 google-api 建立多個帳號(service accounts) 一個 projec 建立 100 個帳號(service accounts),Autorclone 也可以 copy 資料
- gclone(在新分頁開啟):copy 資料使用及 rclone 所有功能
- rclone(在新分頁開啟):可掛載雲端硬碟,上傳,下載,更多功能..,請到官方看看
- service accounts,簡稱 sa(在新分頁開啟):用來突破單日帳號限制 750GB 流量
-
每日上傳檔案數量上限
- 個別使用者每天只能在「我的雲端硬碟」和所有共用雲端硬碟上傳 750 GB 的檔案。當使用者達到 750 GB 的上限或上傳大於 750 GB 的單一檔案,當天就無法再上傳其他檔案,不過上傳中的檔案仍可以完成上傳。可以上傳或同步處理的個別檔案大小上限則為 5 TB。
-
取得無限空間帳號 如果是教育或企業帳號可以選擇共享資料夾或是共享硬碟,如果是一般帳號只有 15GB 容量必須使用共享硬碟(團隊盤) 台灣大學專校都已經使用 G Suite 教育版,想要使用 google 教育帳號可以去自己學校網站看看,只要學校信箱是 google gmail 就可以使用 google 任何服務,共享雲端硬碟要看 G Suite 管理員有沒有開放權限使用,也可以使用教育帳號個人雲端,因為教育帳號已經是無限空間了,所以教育帳號使用共享雲端硬碟就不是很重要了。
-
其他取得方法可以到蝦皮、露天拍賣網站上看看 搜尋 google 教育(請不要買純新增共享雲端硬碟的這是很浪費錢的(找認識的朋友幫妳新增一個共享雲端硬碟或是往下看取得免費共享雲端硬碟),請購買 google 教育帳號,企業帳號也不要買萬一賣家不在付費 G Suite 也等於無限空間失效),以上個人的分析
取得免費的 Team Drive 共享雲端硬碟(團隊盤)
不要放重要的資料,建議申請 Team Drive 使用英文名稱
- Google TeamDrive:td.fastio.me(在新分頁開啟)
- YesYesxx.Me:gd.zxd.workers.dev(在新分頁開啟)
- 404 NOT FOUND:leon.educationhost.cloud(在新分頁開啟)
- 台灣中正大學:gd.404edu.workers.dev(在新分頁開啟)
- 英國老牌名校謝菲爾德大學:gdrive.zppcw.cn(在新分頁開啟)
- 洛杉磯加利福尼亞大學:ucla.ur.workers.dev(在新分頁開啟)
- 日本國際大學:iuj.ur.workers.dev
- 美國西南學院:teamdrive.xcpx.workers.dev(在新分頁開啟)
windows 10
前置安裝及設定
- 需要的工具
- python 3.7 下載(在新分頁開啟)
- gclone 下載(在新分頁開啟) 選擇 Windows_x86_64 版本
- rclone(在新分頁開啟) 依自己的位元下載,AutoRclone 需要用到 Rclone
- AutoRclone(在新分頁開啟)
- 下載方法

- 下載方法
安裝 python 3
PATH 打勾 加入到環境變數,選擇 Install Now,安裝完後就可以了

打開 命令列 cmd,可以直接在 windows 10 右下搜尋 cmd

輸入 python --version
有版本號代表安裝正常
C:\Users\mypc>python --versionPython 3.7.7安裝 gclone
https://github.com/donwa/gclone/releases/tag/v1.51.0-mod1.3.1(在新分頁開啟)
解壓縮後會有個gclone.exe 放到你想要的資料夾
放到 C:\gclone 資料夾內作為示範

啟動環境變數
快捷鍵:win + R
輸入:rundll32.exe sysdm.cpl,EditEnvironmentVariables

加入 gclone 到 path

重開打開一個 cmd
輸入 gclone -h 會列出指令使用說明代表安裝正常

安裝 Rclone
與 gclone 安裝相似
啟動環境變數
快捷鍵:win + R
輸入:rundll32.exe sysdm.cpl,EditEnvironmentVariables
加入,依照你放的路徑為主
C:\rclone-v1.52.2-windows-amd64
開啟命令列輸入 rclone -h,若有跑出訊息就是安裝成功
安裝 AutoRclone 及設定
將AutoRclone(在新分頁開啟)下載的 AutoRclone-master.zip 檔案解壓縮
開啟 cmd
切換到 AutoRclone-master 資料夾位置,以你的放置位置為準

輸入,會自動安裝相關的套件
pip install -r requirements.txt
啟用 dirve api

下載後會得到一個credentials.json,請將credentials.json 放入到AutoRclone-master資料夾內
如下

自動建立 service 帳號
建立 100 個 service 帳號,每個 project 能建立 100 個 service 帳號 以指令是建立 6 個 project 有 600 個 service 帳號,計算一下 600 * 750GB = 450,000 GB,建議不要建立太多個 project
python gen_sa_accounts.py --quick-setup 5- 創建 6 個項目(項目 0 到項目 5)
- 開啟相關的服務
- 創建 600 個 service accounts(6 個項目,每個項目 100 個)
- 將 600 個 service accounts 的授權文件下載到 accounts 資料夾下面
如果你已經有 N 個項目,現需要創建新的項目並在新的項目中創建 service accounts,直接運行
python gen_sa_accounts.py --quick-setup 2 --new-only- 額外創建 2 個項目(項目 N+1 到項目 N+2)
- 開啟相關的服務
- 創建 200 個 service accounts(2 個項目,每個項目 100 個)
- 將 200 個 service accounts 的授權文件下載到 accounts 資料夾下面
複製產生的網址


一路按下允許

複製授權碼到 CMD 視窗上,按下 ENTER

複製網址,啟用 Service Usage API,在回到 CMD 視窗按下 ENTER,會自動開啟建立 service 帳號



建立完成後,到accounts資料夾看到非常多的 json 檔,每個 json 檔都是一個 service 帳號

加入 service 帳號到 team drive
-
成員限制說明:https://support.google.com/a/answer/7338880?hl=zh-Hant(在新分頁開啟)
-
有兩種方法,任選一種
- 第一種使用 python 腳本自動將所有的 service 帳號加入到 team drive,最多能加 600 個帳號,這是最快的方法,
- 第二種 使用 groups 論壇,建立群組並手動加入 service 帳號,一天最多加入 100 個,這種方法會比較慢,但是可以加入非常多個,之後只需要將 groups 論壇的管理員 email 加入到 team dirve 就可以了
- 注意:如果是請朋友幫你加入共享雲端硬碟,必須是管理員權限
-
使用 python 腳本自動將所有的 service 帳號加入到 team drive 指令, SharedTeamDriveSrcID 改成 team drive 的 ID
python add_to_team_drive.py -d SharedTeamDriveSrcID取得 team drive 的 ID,例如:0AL9kUqtQlodwUk9PVA


注意:一個 team drive 最多只能加入 600 個使用者
如果有 600 個 service 帳號卻沒有加入滿到 600,只需要多執行幾次就可以,直到加入到 600 個
到這裡就快完成啦
- 使用 groups 論壇,建立群組並手動加入 service 帳號
使用 python 腳本 將每個 json email 整理至一個文件內,方便複製加入
將腳本下載放至AutoRclone-master資料夾內
python 腳本下載(在新分頁開啟)
執行命令,跑完之後資料夾內會出現一個 email.txt,打開此文件
python find_email_to_save_txt.py建立 群組論壇
groups.google.com(在新分頁開啟)
注意:一天只能新增 100 個成員

取得群組 email (非常重要)

將群組 EMAIL 加入到 Team drive

GSuite Admin 加入成員方法 step-3-add-service-accounts-to-google-groups-optional-but-recommended-for-hassle-free-long-term-use(在新分頁開啟)
gclone 建立設定
gclone config

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 / Transparently chunk/split large files \ "chunker"32 / Union merges the contents of several remotes \ "union"33 / Webdav \ "webdav"34 / Yandex Disk \ "yandex"35 / http Connection \ "http"36 / premiumize.me \ "premiumizeme"Storage> 13 < 輸入 13 google drive** See help for drive backend at: https://rclone.org/drive/ **
Google Application Client IdSetting 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> (留空白 按ENTER,官方建議可以使用自己的client_id,可以避免官方api過度使用導致調用失敗)Google Application Client SecretSetting your own is recommended.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 folderLeave blank normally.
Fill in to access "Computers" folders (see docs), or for rclone to usea non root folder as its starting point.
Note that if this is blank, the first time rclone runs it will fill itin with the ID of the root folder.
Enter a string value. Press Enter for the default ("").root_folder_id> (留空白,如果想要以一個資料夾為根目錄可以輸入該資料夾ID)Service Account Credentials JSON file pathLeave 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>/AutoRclone-master/accounts/00af8bc13083978e5ad222c77380c3b6877fdeda.json (到accounts資料夾隨便找一個json檔名,不要輸入與我一樣的,每個人路徑與檔名都不同)Service Account Credentials JSON file path .
Enter a string value. Press Enter for the default ("").service_account_file_path> /AutoRclone-master/accounts/ (後面必須加入/,不輸入/可能出錯)Edit advanced config? (y/n) (此部分是高級設定)y) Yesn) No (default)y/n> n (輸入n)Configure this as a team drive? (是否使用 team drive 輸入Y)y) Yesn) No (default)y/n> yFetching team drive list...Choose a number from below, or type in your own value 1 / share_gogogo (這是我的team drive,每個人名稱不同,如果有多個team drive 選擇自己要的team drive) \ "0AL9kUqtQlodwUk9PVA"Enter a Team Drive ID> 1--------------------[gd_team]type = drivescope = driveservice_account_file = /AutoRclone-master/accounts/00af8bc13083978e5ad222c77380c3b6877fdeda.jsonservice_account_file_path = /AutoRclone-master/accounts/team_drive = 0AL9kUqtQlodwUk9PVA--------------------y) Yes this is OK (default)e) Edit this remoted) Delete this remotey/e/d> y (輸入Y)
(需要注意你的name,copy資料需要用到)Name Type==== ====gd_team drive
e) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q 按Q退出到這裡就設定完成啦,接下來看看如何使用 gclone copy 資料,copy 到你看不完的資料
之後想要更改設定只需要再輸入 gclone config 再輸入 E 即可編輯設定
>gclone configCurrent remotes:
Name Type==== ====gd_team drive
e) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> e指令使用方式
gclone 指令
gclone copy gd_team:{源} gd_team:my team name/資料夾1/資料夾2/ --drive-server-side-across-configs -v實際使用方法:
我的共享盤名稱是:share_gogogo
要 copy 的檔案:https://drive.google.com/uc?id=1l_dr7tqoNZja94b_AZ3LLmfLr8xk4g8x(在新分頁開啟)
取得網址的 ID,1l_dr7tqoNZja94b_AZ3LLmfLr8xk4g8x
因為設定時候已經設定好 team drive,所以不用再次輸入 team drive 名稱
gclone copy gd_team:{1l_dr7tqoNZja94b_AZ3LLmfLr8xk4g8x} gd_team:雷電模擬器 --drive-server-side-across-configs -v
資料夾結構

也可以指定其他 team drive,注意必須要加入權限帳號,有允許權限才能複製到指定的雲端硬碟
gclone copy gc:{folde_id1} gc:{folde_id2} --drive-server-side-across-configsAutorclone 指令
使用 Autorclone copy 資料
需求:rclone
- rclone 安裝
- 下載 rclone(在新分頁開啟),需注意妳的作業系統及位元

- 解壓縮檔案後,會得到
rclone-v1.52.3一個資料夾- 放到 C 槽並加入環境變數
啟動
環境變數快捷鍵:win+R輸入:rundll32.exe sysdm.cpl,EditEnvironmentVariables
重新開啟 cmd 輸入 rclone -h ,有顯示一推指令說明 代表安裝正常
- 放到 C 槽並加入環境變數
啟動
- 下載 rclone(在新分頁開啟),需注意妳的作業系統及位元
SourceID = 源檔案,需 copy 的資料 ID DestinationID = 自己的 team drive id DestinationPathName = 路徑(資料夾) 會自動建立資料夾,不需要手動新增
python rclone_sa_magic.py -s SourceID -d DestinationID -dp DestinationPathName -b 1 -e 600取得自己 team drive id

檢查大小 如果沒有源路徑及目標路徑 不需輸入,路徑也就是資料夾意思 rclone —config rclone.conf size —disable ListR src001<源路徑>源路徑> rclone —config rclone.conf size —disable ListR dst001<目標路徑>目標路徑>
指令幫助說明
python rclone_sa_magic.py -hAutoRclone 作者的教學 https://gsuitems.com/index.php/archives/13/(在新分頁開啟)
建立自己的 client_id
-
使用自己的 client_id,可以使用任何帳號的 api,不影響使用的雲端硬碟帳號 https://github.com/rclone/rclone/blob/8d55367a6a2f47a1be7e360a872bd7e56f4353df/docs/content/drive.md#making-your-own-client_id(在新分頁開啟)
-
開啟此頁面 https://console.developers.google.com/apis/credentials(在新分頁開啟)

修改 client_id 及 client_secret
c:\AutoRclone-master>gclone configCurrent remotes:
Name Type==== ====gd_team drive
e) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> eChoose a number from below, or type in an existing value 1 > gd_teamremote> 1--------------------[gd_team]type = drivescope = driveservice_account_file = /AutoRclone-master/accounts/00af8bc13083978e5ad222c77380c3b6877fdeda.jsonservice_account_file_path = /AutoRclone-master/accounts/team_drive = 0AL9kUqtQlodwUk9PVA--------------------Edit remote** See help for drive backend at: https://rclone.org/drive/ **
Value "client_id" = ""Edit? (y/n)>y) Yesn) No (default)y/n> yGoogle Application Client IdSetting 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> 75484848268-tr0lm3aoi6a6uuedv0bn2fnrsjqqvqep.apps.googleusercontent.comValue "client_secret" = ""Edit? (y/n)>y) Yesn) No (default)y/n> yGoogle Application Client SecretSetting your own is recommended.Enter a string value. Press Enter for the default ("").client_secret> dJty5bR1TXYVzRyuS9JmQ8u0Value "scope" = "drive"Edit? (y/n)>y) Yesn) No (default)y/n> nValue "root_folder_id" = ""Edit? (y/n)>y) Yesn) No (default)y/n> nValue "service_account_file" = "/AutoRclone-master/accounts/00af8bc13083978e5ad222c77380c3b6877fdeda.json"Edit? (y/n)>y) Yesn) No (default)y/n> nValue "service_account_file_path" = "/AutoRclone-master/accounts/"Edit? (y/n)>y) Yesn) No (default)y/n> nEdit advanced config? (y/n)y) Yesn) No (default)y/n> n--------------------[gd_team]type = drivescope = driveservice_account_file = /AutoRclone-master/accounts/00af8bc13083978e5ad222c77380c3b6877fdeda.jsonservice_account_file_path = /AutoRclone-master/accounts/team_drive = 0AL9kUqtQlodwUk9PVAclient_id = 75484848268-tr0lm3aoi6a6uuedv0bn2fnrsjqqvqep.apps.googleusercontent.comclient_secret = dJty5bR1TXYVzRyuS9JmQ8u0--------------------y) Yes this is OK (default)e) Edit this remoted) Delete this remotey/e/d> yRemote configChange current team drive ID "0AL9kUqtQlodwUk9PVA"?y) Yesn) No (default)y/n> nCurrent remotes:
Name Type==== ====gd_team drive
e) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q>問題
使用 gclone 可以傳送幾個檔案之後會有錯誤訊息 panic: runtime error: invalid memory address or nil pointer dereference
為了快速解決問題,不使用 gclone 指令,建議直接使用 Autorclone 指令處理
問題除錯
編輯設定指令:gclone config root_folder_id 有錯誤的話,無法複製到你指定的共享資料夾及團隊盤 確定 root_folder_id 是否為""(空) 或是 輸入正確資料夾 ID
參考文章
若此篇文章你還是看不懂,請看下列的文章及影片
- http://fxxkr.com/2020/03/27/autorclone-gclone-googledrive/(在新分頁開啟)
- https://github.com/donwa/gclone/blob/master/README_zh.md(在新分頁開啟)
- https://www.youtube.com/watch?v=EJMZCnGIEVY(在新分頁開啟)
- https://gsuitems.com/index.php/archives/13/(在新分頁開啟)
- https://zhuanlan.zhihu.com/p/124305044(在新分頁開啟)
- https://github.com/iwestlin/gd-utils#%E6%90%AD%E5%BB%BA%E8%BF%87%E7%A8%8B(在新分頁開啟)
- https://www.stevenz.tech/gd-750g/#gd-utils(在新分頁開啟)
- https://shikey.com/2020/05/22/win10-gclone-autoclone-750g.html(在新分頁開啟)
- http://blog.jialezi.net/?post=153(在新分頁開啟)
