I'm new to shell scripting and wanted to insure I haven't made any errors in creating this script for making a borg
backup to a flashdrive that I plug into my computer.
Does the below script look solid? (I made it executable and put it in my
/usr/local/bin/
)I added the "date" command substitution within the "borg" command substitution. Is this allowed? Are there any rules that frown on putting command substitutions within command substitutions?
Does the entire line need quotes (") around it, like I have done?
#!/bin/bash
echo "$(borg create /media/$USER/Flashdrive/backup::$(date +%FT%H%M) /home/$USER/Documents)"
stuff
? – steeldriver Apr 19 '20 at 01:00echo
and the first command substitution are not needed (but the outer quotes around the command substitution would be correct). Andborg
allows a few placeholders in the archive name, so you could write the date as{now:%Y-%m-%dT%H%M}
(maybe%F
instead of%Y-%m-%d
works too, I just haven't seen an example in the manual). – Freddy Apr 19 '20 at 01:26echo
? Rather thanecho $(borg …)
, why not just run theborg …
command? – G-Man Says 'Reinstate Monica' Jul 30 '20 at 20:54