HOME | linux | rclone - 用command line存取各種雲端硬碟

rclone - 用command line存取各種雲端硬碟

2019/03/15/15:01 , Post in linux , 評論(0) , 引用(0) , 閱讀(2623) , Via 本站原創
會想到再linux上同步資料到google drive或是dropbox主要是有些比較重要的資料

加密之後放在公有雲上還是比放在自己的NAS之類的上面安全(至少不用維護)

畢竟有時候自己的檔案伺服器會碰到停電、斷網,甚至硬碟故障的問題才衍生出這個需求
rclone是一套公開的軟體,支援的雲端硬碟非常多,我先用centos 7做範例

首先到官網直接下載相對應的rclone

下載後直接解壓縮,unzip 後裡面最主要就一個執行檔而已先測試一下你的版本對不對


./rclone --version
rclone v1.46- os/arch: linux/amd64-
go version: go1.11.5

看起來沒錯,接下來進行設定,(以下建議找一台WINDOWS下載rclone後進行設定)

rclone config
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n                 #新建一個連線
name> test              #連線名稱
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 Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
   \ "s3"
5 / Backblaze B2
   \ "b2"
6 / Box
   \ "box"
.....
Edit advanced config? (y/n)
y) Yes
n) No
y/n> 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
n) No
y/n> y


我先用google drive做DEMO,選擇12,接著就一路enter,中間問你要給什麼樣的權限

接著是是否要進階設定,結束後會開啟瀏覽器讓你登入google帳號,點允許rclone權限


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
Configure this as a team drive?
y) Yes
n) No
y/n> y


接著底下就是一個設定檔

[test]
type = drive
scope = drive.readonly
token = {"access_token":"xxx","token_type":"Bearer","refresh_token":"xxx","expiry":"2019-03-15T15:42:23.301164+08:00"}

結束設定,把這段config複製到linux上的/root/.config/rclone/rclone.conf

接下來就可以直接操作了,以下列出一些比較簡單常用的指令

rclone ls --max-depth 1 test:/   #列出第一層的檔案

./rclone copy -v 測試上傳 test:/測試上傳   #上傳

./rclone copy -v:/測試下載 ./   #下載

接下來只要搭配cronjob就可以定時的把一些重要資料送到公有雲上了

發表評論

暱稱

網址

電郵

開啟HTML 開啟UBB 開啟表情 隱藏 記住我 [登入] [註冊]