34 lines
3.6 KiB
Markdown
34 lines
3.6 KiB
Markdown
Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors' web storage interfaces. Over 70 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.
|
|
|
|
!!! warning "Be Mindful of Sync Type"
|
|
The `bisync` command is meant to keep multiple locations synced with eachother, while in contrast the `sync` command forces the source to overwrite the destination. If you just want to dump the source into the destination on top of existing data, use the `copy` command within rclone.
|
|
|
|
## Usage Overview
|
|
There is a lot to keep in mind when using rclone, primarily with the `sync` command. You can find more information in the [Official Documentation](https://rclone.org/commands/)
|
|
|
|
## rClone `bisync` Implementation
|
|
Perform bidirectional synchronization between two paths. Bisync provides a bidirectional cloud sync solution in rclone. It retains the `locationA` and `locationB` filesystem listings from the prior run. On each successive run it will:
|
|
|
|
- List files on `locationA` and `locationB`, and check for changes on each side. Changes include `New`, `Newer`, `Older`, and `Deleted files`.
|
|
- Propagate changes on Path1 to Path2, and vice-versa.
|
|
|
|
### Example Usage
|
|
The following commands illustrate how to use bisync to synchronize a local folder and a remote folder (assumed to be Google Drive). The `--drive-skip-gdocs` flag simply does not sync Google Drive specific documents back to the local folder, such as `*.gsheet`, `*.gdoc`, etc. The `--resilient` flag means that if there are network interruptions, rclone will attempt to recover on its own automatically to resume where it last left off in the sync.
|
|
|
|
=== "Initial Sync"
|
|
We want to first sync down any files that are from the remote location (Google Drive/Remote Folder/Network Share/etc) and overwrite any local files with the newer files. This ONLY overwrites local files that are older than the remote files, but if the local files are newer, they are left alone. `--update` = (Skip files that are newer on the destination) > This allows us to ensure that the newest changes on Google Drive are pulled down before performing a bisync.
|
|
|
|
```powershell
|
|
.\rclone.exe sync "Remote" "Local" --update --log-level INFO --drive-skip-gdocs --create-empty-src-dirs --progress
|
|
```
|
|
|
|
=== "Subsequent Syncs"
|
|
At this point, the local directory has the newest remote version of all of the files that exist in both locations, so if anyone made changes to a file in Google Drive, and those changes are newer than the local files, it overwrites the local files, but if the local files were newer, they were left alone. This second command performs the first and all subsequent bisyncs, with conflict resolution, meaning:
|
|
- If the remote file was newer, it deletes the older local file and overwrites it with the newer remote file,
|
|
- If the local file was newer, it deletes the older remote file and overwrites it with the newer local file
|
|
```powershell
|
|
.\rclone.exe bisync "Local" "Remote" --create-empty-src-dirs --conflict-resolve newer --conflict-loser delete --compare size,modtime,checksum --resilient --log-level ERROR --drive-skip-gdocs --fix-case --force --progress
|
|
```
|
|
|
|
!!! info
|
|
The `--conflict-resolve newer` flag is how the bisync determines how to declare a "winner" and a "loser", the winner being the newer file, and the loser being the older file. The `--conflict-loser delete` is the action to perform to the older file when a conflict is found in either direction. |