ใช้ Rclone สำรองข้อมูลบน Linux ไปไว้ใน Google Drive
เตรียม
- แอดมินใช้ Debian 64 bit เป็น Data ฝั่ง Source
- แอดมินใช้ Google Drive เป็น Data ฝั่ง Destination
ติดตั้ง Package พื้นฐาน
apt install sudo curl unzip
ติดตั้ง Rclone
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-*-linux-amd64
sudo cp rclone /usr/bin/
sudo chown root:root /usr/bin/rclone
sudo chmod 755 /usr/bin/rclone
ตั้งค่า Rclone
rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
Enter name for new remote.
name> Gdrive
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
Storage> 18
Option client_id.
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 value. Press Enter to leave empty.
client_id> XXXXXXXXXXXXXXXXXXXXXXX
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> XXXXXXXXXXXXXXXXXXXXXXX
scope> 1
Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>
Edit advanced config?
y) Yes
n) No (default)
y/n> n
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
Option config_token.
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 "drive" "XXXXXXXXXXXXXXXXXXXXX"
Then paste the result.
Enter a value.
config_token> XXXXXXXXXXXXXXXXXXXXX
Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n> n
Configuration complete.
Options:
- type: drive
- scope: drive
- team_drive:
Keep this "Gdrive" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> 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
List ดูไฟล์ใน Google Drive
rclone ls remote:
Copy ไฟล์ไปไว้ใน Google Drive
rclone copy /home/source remote:backup
Sync ไฟล์ไปไว้ใน Google Drive
rclone sync /home/source remote:backup