Mount google drive, onedrive vào folder của linux

Case study: Cần giải pháp backup file rẻ tiền cho cái blog devopsvn.xyz

Hàng ngày source code và database được dump ra file à đồng bộ file đó lên google drive

Tiến hành:

Để mount folder sử dụng rclone

curl https://rclone.org/install.sh | sudo bash

  • Cấu hình với goole drive: cần chuẩn bị các thông tin dưới đây:
    • https://developers.google.com/identity/sign-in/web/sign-in?refresh=1 truy cập trang này và tạo 1 project, sau đó làm theo hướng dẫn. sẽ thu được client id và client_secret
      • client_secret
      • client_id
    • Trong quá trình chạy thử sẽ thấy không đăng nhập được, trên màn hình console sẽ hướng dẫn truy cập các đường link để xác thực và cấp quyền. Lưu ý theo dõi

rclone config
No remotes found - make a new one
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n
name> remote
Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
10 / Google Drive
\ "drive"
[snip]
Storage> drive
Google Application Client Id - leave blank normally.
client_id>
Google Application Client Secret - leave blank normally.
client_secret>
Scope that rclone should use when requesting access from drive.
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
ID of the root folder - leave blank normally. Fill in to access "Computers" folders. (see docs).
root_folder_id>
Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file>
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> y
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> n
--------------------
[remote]
client_id =
client_secret =
scope = drive
root_folder_id =
service_account_file =
token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y

Chú ý: trong quá trình config có thông tin scope, ở trên thông tin này là drive

Thông tin này sử dụng để thao tác sau này:

Cú pháp mount

ví dụ

Tham số –daemon thể hiện tiến trình mount chạy ẩn dưới background.