Last year I created an rsync tool for myself. In short, It's purpose was to build rsync commands within a config file and use those files to build and run rsync commands. I preferred this over the every growing list of rsync commands I was experiencing. Making aliases for everything and keeping commands unified and neat was becoming overwhelming for myself.
Recently I've been sick so I used my free time to completely rewrite the script using all the knowledge I've learned over the last year writing some other scripts. I took out some features that were too specific, made the code much cleaner and easier to maintain and made the visual output easier to read and understand.
The script has a number of additional features including:
- Running multiple config files from a single command
- The base command will do a dry run to allow you to preview changes before committing to a transfer
- An option to quickly do a dry run to simply view any changes
- An option to quickly reverse the source/destination transfer direction
- An option to ignore the dry run and instantly perform a sync
- The ability to create a template config file that's (hopefully) easy to read and fill out
- Feedback for a number of common issues so that the rsync command will not run, hopefully avoiding any data loss issues
- An option to print out the full rsync command built from a config file (sometimes I want to move a specific file without creating a new, one time use config file)
- Built with
sshand ssh key files in mind - Single file and POSIX portable with
rsyncas it's only dependency - Long command option names for easier scripting
One notable change I made from my first script and the rewrite was using the sed command to gather information from the config files instead of directly sourcing into the main script. It's slightly less efficient but more secure than accidentally running commands while using the source (.) command. I'm still trying to figure out how to make it slightly more efficient but for now it works how I like it to work.
I've had such terrible luck with fully featured syncing programs (Syncthing for example) and have always had much better consistency with rsync (at the loss of bi-directional, continuous syncing). I also hated building rsync commands so this tool has been a great compromise for myself.
