# Backup data ด้วย Rclone



# ใช้ Rclone สำรองข้อมูลบน Linux ไปไว้ใน Google Drive

### เตรียม

\- แอดมินใช้ Debian 64 bit เป็น Data ฝั่ง Source

\- แอดมินใช้ Google Drive เป็น Data ฝั่ง Destination

### ติดตั้ง Package พื้นฐาน  


```shell
apt install sudo curl unzip
```

### ติดตั้ง Rclone  


```shell
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

```shell
rclone config
```

No remotes found, make a new one?  
n) New remote  
s) Set configuration password  
q) Quit config  
<span style="background-color: #bfedd2;">n/s/q&gt; n</span>

Enter name for new remote.  
<span style="background-color: #bfedd2;">name&gt; Gdrive</span>

Option Storage.  
Type of storage to configure.  
Choose a number from below, or type in your own value.

<span style="background-color: #bfedd2;">Storage&gt; 18</span>

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.  
<span style="background-color: #bfedd2;">client\_id&gt; XXXXXXXXXXXXXXXXXXXXXXX</span>

Option client\_secret.  
OAuth Client Secret.  
Leave blank normally.  
Enter a value. Press Enter to leave empty.  
<span style="background-color: #bfedd2;">client\_secret&gt; XXXXXXXXXXXXXXXXXXXXXXX</span>

<span style="background-color: #bfedd2;">scope&gt; 1</span>

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.  
<span style="background-color: #bfedd2;">service\_account\_file&gt;</span>

Edit advanced config?  
y) Yes  
n) No (default)  
<span style="background-color: #bfedd2;">y/n&gt; n</span>

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  
<span style="background-color: #bfedd2;">y/n&gt; n</span>

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.  
<span style="background-color: #bfedd2;">config\_token&gt; XXXXXXXXXXXXXXXXXXXXX  
</span>

Configure this as a Shared Drive (Team Drive)?

y) Yes  
n) No (default)  
<span style="background-color: #bfedd2;">y/n&gt; n</span>

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  
<span style="background-color: #bfedd2;">y/e/d&gt; y</span>

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  
<span style="background-color: #bfedd2;">e/n/d/r/c/s/q&gt; q</span>

### List ดูไฟล์ใน Google Drive  


```
rclone ls remote:
```

### Copy ไฟล์ไปไว้ใน Google Drive

```shell
rclone copy /home/source remote:backup
```

### Sync ไฟล์ไปไว้ใน Google Drive

```shell
rclone sync /home/source remote:backup
```

### ดูคำสั่งอื่นๆของ Rclone

[https://rclone.org/commands/](https://rclone.org/commands/)