Sync với Google Drive

crazybird275

New member
** Đồng bộ với Google Drive **

Cách dễ nhất để đồng bộ hóa một thư mục cục bộ với thư mục từ xa của Google Drive hoặc ngược lại, là sử dụng tập lệnh chạy định kỳ qua Crontab.Điều này sẽ đảm bảo rằng các tệp luôn được cập nhật, mà không phải theo dõi thủ công các thay đổi trong thư mục.

Ví dụ: tập lệnh sau đây sẽ đồng bộ hóa thư mục `/home/pi/tài liệu` với thư mục từ xa của` my-google-folder` sau mỗi 15 phút: cứ sau 15 phút:

`` `
#!/Bin/bash

# Đồng bộ hóa thư mục cục bộ với thư mục từ xa
Rclone Sync/home/pi/tài liệu của tôi-google-drive folder-delete-after --exclude "*.tmp" --Exclude "*.bak"

# Ngủ trong 15 phút
Ngủ 15m
`` `

Sau đó, bạn có thể thêm tập lệnh này vào crontab của mình bằng cách chạy lệnh sau:

`` `
crontab -e
`` `

Và thêm dòng sau vào cuối tệp:

`` `
*/15 * * * * /home/pi/sync-with-google-ridrive.sh
`` `

Điều này sẽ đảm bảo rằng tập lệnh chạy cứ sau 15 phút, giữ thư mục cục bộ và thư mục Google Drive của bạn đồng bộ.

** Mẹo thưởng: ** Bạn cũng có thể sử dụng tập lệnh này để đồng bộ hóa nhiều thư mục với các thư mục từ xa khác nhau.Chỉ cần tạo một tập lệnh riêng cho mỗi thư mục, sau đó thêm tất cả vào crontab của bạn.
=======================================
**Sync with Google Drive**

The easiest way to sync a local directory with a Google Drive remote folder, or vice versa, is to use a script that runs periodically via crontab. This will ensure that the files are always up-to-date, without having to manually monitor the changes in the folder.

For example, the following script will sync the `/home/pi/Documents` directory with the `my-google-drive-folder` remote folder every 15 minutes:

```
#!/Bin/bash

# Sync the local directory with the remote folder
rclone sync /home/pi/Documents my-google-drive-folder --delete-after --exclude "*.tmp" --exclude "*.bak"

# Sleep for 15 minutes
sleep 15m
```

You can then add this script to your crontab by running the following command:

```
crontab -e
```

And adding the following line to the end of the file:

```
*/15 * * * * /home/pi/sync-with-google-drive.sh
```

This will ensure that the script runs every 15 minutes, keeping your local directory and Google Drive folder in sync.

**Bonus tip:** You can also use this script to sync multiple directories with different remote folders. Simply create a separate script for each directory, and then add them all to your crontab.
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top