rClone
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.
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
rClone bisync
Implementation¶
Perform bi-directional synchronization between two locations (e.g. Local
and Remote
). Bisync provides a bi-directional cloud sync solution in rclone. It retains the file structure and history data in both the Local
and Remote
locations from the first time you run bisync.
Example Usage¶
The following commands illustrate how to use bisync to synchronize a local folder and a remote folder (assumed to be Google Drive).
Explanation of Command Arguments
--drive-skip-gdocs
: This prevents the sync from syncing Google Drive specific documents such as*.gsheet
,*.gdoc
, etc.--resilient
: This means that if there are network interruptions, rclone will attempt to recover on its own automatically.--conflict-resolve newer
: This 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.
--conflict-loser delete
: This is the action to perform to the older file when a conflict is found in either direction.--update
: This skips files that are newer on the destination, allowing us to ensure that the newest changes on the remote storage are pulled down before performing our first bisync.
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.
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
If you find your bisync has somehow gone awry, and you need to re-create the differencing databases that are used by rclone to determine which files are local and which are remote, you can run the following command to (non-destructively) re-build the databases to restore bisync functionality.
The only core difference between this command and the "Subsequent Sync" command, is the addition of --resync
to the argument list.