Simple and effective CLI-fronted for rclone.
rc provides a flexible command subset for advanced bi-directional sync over multiple rclone remotes.
Let's say we have several configured remotes in rclone config:
db— Dropbox remote;yd— Yandex Disk remote;- ...any other remotes with supported backend.
Assuming this, let's see how rc helps to manage vaults over these storage backends:
| Command | Description |
|---|---|
rc db |
Sync local folder ~/db/ to remote db:/ |
rc yd:/vim |
Sync local folder ~/yd/vim/ to yd:/vim/ |
rc docs |
Encrypt local folder ~/Documents/work and sync encrypted files to remote db:/encrypted, |
rc books:/Zelazny down |
Sync remote folder db:/library/Zelazny/ to ~/calibre/Zelazny |
The core idea of rc is to define several higher-level remotes in rc config, which inherit actual rclone ones. When you run rc books:/Zelazny down command, the following pipeline is applied:
rcparses provided arguments:books— remote name;/Zelazny— so-called userPath;down— sync direction. Down means "from remote to local", and vice versa.
rcsearches for remotebooksin.config.yml. Let's say config is:base_dir: /Users/user options: exclude: [".DS_Store"] remotes: books: remote: db path: /library local_path: /calibre
rcbuild local dir path and remote one:- Local:
base_dir + (remote | local_path) + userPath. Will generate/Users/user/calibre/Zelazny/. - Remote:
remote:remote_path + userPath. Will generatedb:/library/Zelazny/.
- Local:
rcapplies options from global config options, such asexclude.rcrunsrclone --exclude=.DS_Store sync db:/library/Zelazny /Users/user/calibre/Zelazny
You may wish to encrypt remote files and sync to remote directory like enc_storage. To do this:
- Create with
rclone configactual storage backend in rclone, for exampledb<Dropbox>, or use existing. - Create with
rclone configcrypt storage backend in rclone. Forpath, specify actualremoteandpath, where encrypted files will be physically placed on remote storage. Example:db:/enc_storage. - Create rc-remote in config, e. g.
docs. Forremotespecify crypt storage from step 2.- By default, the same
local_pathrules are applied: decrypted files locally will be placed to<base_dir>/<remote_path>. If you specifylocal_path, decrypted files will be stored in<base_dir>/<local_path>.
- By default, the same
- Run
rc docs. It will encrypt<base_dir>/<remote_path | local_path>and upload to<remote>:<path>, specified in rclone config.
rc <remote:path> <direction>
<remote:path>: rc-remote and userPath to specify nested sync directory<direction>:upordown, sync direction.upis default and my be omited.
Example config:
base_dir: /Users/user
remotes:
stuff:
remote: yd
books:
remote: yd
path: /library
local_path: /calibre
docs:
remote: crypt_docs
remote_path: /
local_path: /Documents/docsConfig params:
base_dir: absolute path on filesystem, which all other remotes are relative to.remotes: a named list of Remotes.
Remote params:
remote, required: rclone remote to use, should exist in rclone config;remote_path, optional: directory to sync on remote storage. Used as local_path, if the last is not provided.local_path, optional: directory to sync on local storage. Overwritesremote_pathfor building local target path.
There are several bugs and featured, I'm going to implement in future. Please, feel free to open PR.
local_pathcannot contains spaces. For some reasons runningexec.Command()with spaces in one of args raises incorrect argument parsing, even with quoting / escape. Running the same arguments in bash works properly.- rc must failback to rclone remotes with the same argparse logic if requested remote was not found in rc config. Right now this code block is commented.
Please, note, rc is in alpha. Though critical functions are partly tested, use it at your own risk.
Copyright (c) 2018 Ilya Rusanen
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.