Created a tool for Rsync transfers

a year ago by confusedpuppy to c/shell

A command line tool used to simplify and run rsync commands from config files. Feedback helps safely build rsync commands before use.

Ever since I started down the self-hosting rabbit hole one issue I've been constantly annoyed with is transferring files between machines. Especially files which I am currently working on and that I want to periodically transfer to a specific remote location.

Rsync has been my go to tool for file transfers and backups but I absolutely hate making commands for it. I was getting lost in a wall of text with all my rsync aliases.

The script I created helps me organize those commands by placing all the information for an rsync command into an easier to read dot-file. The script will read the dot-file, update the rsync command and run it. It's also set up to preview file transfers with rsync's dry run option. I've also added a few other features to make the script more flexible including being able to quickly backup a directory that I'm currently working in.

For self-hosting, I find working with files a bit easier to organize than a text full of aliases although I can see it easy to get overwhelmed with dot-files if some people aren't organized.

I've also made it as POSIX shell friendly as possible. I know a couple things I did aren't fully POSIX compliant currently but I that's something to work towards. This is also the first programming thing I ever completed so I'm quite happy with how it turned out.

If at least one other person finds this script useful, that would be pretty neat :)

mundane 4 points a year ago

Using sudo in all of your examples is a red flag that might deter people.

path: 0 17767235, hotness: undefined, score: 4, children: 1
confusedpuppy 1 point a year ago

I took sudo out of the examples and disabled it by default within the script. I still have a personal use for it.

I keep a local backup on each device then transfer that backup to my desktop. Rsync requires root access to transfer files or directories with certain attributes over ssh. Otherwise the backup copy to my desktop is incomplete.

Fortunately I already coded in a toggle for requesting root since Termux on Android has no root by default. I just won't note that in the readme file. That can be left for anyone who cares to read the code itself.

path: 0 17767235 17771251, hotness: undefined, score: 1, children: 0
SpaceNoodle 3 points a year ago

Why are superuser privileges necessary? That's highly suspect.

path: 0 17767404, hotness: undefined, score: 3, children: 1
confusedpuppy 3 points a year ago

I use a lot of commands that either use the --delete option or require remote root access in order to preserve hard links and other attributes.

I didn't know that was an issue. I was going from my own limited experience with linux.

I already set an option to disable the root requirement at the beginning of the script. Simply changing the value to 0 will disable it and will let rsync display it's own errors.

What exactly makes it suspect so I know what I'm doing?

path: 0 17767404 17767755, hotness: undefined, score: 3, children: 0
shell
shell

@programming.dev

login for more options
1615
50
1

From Ash, Bash and Csh to Xonsh, Ysh and Zsh; all shell languages are welcome here!

Rules:
  1. Follow Lemmy rules!
  2. Posts must relate to shell scripting. (See bottom of sidebar for more information.)
  3. Only make helpful replies to questions. This is not the place for low effort joke answers.
  4. No discussion about piracy or hacking.
  5. If you find a solution to your problem by other means, please take your time to write down the steps you used to solve your problem in the original post. You can potentially help others having the same problem!
  6. These rules will change as the community grows.

Keep posts about shell scripting! Here are some guidelines to help:

  • Allowed: Release Announcement of a command-line program designed for scripted use (e.g. bash, bats, awk, jq, coreutils/moreutils)
  • Allowed: Tutorials on using shell languages or supplementary tools designed for scripted use
  • Allowed: Code review/help requests for shell languages or supplementary tools designed for scripted use
  • NOT Allowed: Announcement of a CLI or TUI program that is not designed for scripted use (Yes, your fancy Zsh plugin which pretty-prints the date and time using only builtins is very cool, but unless you actually want to discuss the code itself, please check out !commandline instead!)
  • NOT Allowed: Domain-specific tutorials that do not involve shell scripting as a core component (e.g. docker-compose, ansible, nix). If you really love one of these, I'm sure there's a community out there ready to talk about them!
  • NOT Allowed: Code review requests for non-shell programming languages and configuration languages (e.g. Python, Yaml)

In general, if your submission text is primarily shell code, then it is welcome here!

go to feed...