This article describes an example bash shell script which demonstrates a simple method of creating backups of multiple filesystems to several tape drives simultaneously. The example script can easily be modified to write to other device types and to create a different number of backup streams.
I appreciate the attempt, but next time, leave the humor to the pros.
This article was much better six years ago when it was written by Neal Stephenson
uhh, i posted that comment on the OS/Car analogy story…
Bah, why’d you need bash for this? Any Bourne-compatible shell can run this. Stick to POSIX /bin/sh for portable scripts.
“Any Bourne-compatible shell can run this”
Yep, I just tried it — it works fine under /bin/sh.
Seeing if something works with /bin/sh isn’t really a good test of its portability…
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Mar 30 17:26 /bin/sh -> bash
๐
I really don’t see the sense to publish a script every UNIX sysadmin should be able to write in 1 minute. Even in Sh, Ksh, Csh or perl. ๐
Why use /bin/bash? This thing runs in every POSIX-compatible shell. Why hardcode paths of every program you run? Just make sure you have a sane PATH in your environment. Why use /bin/echo when every modern shell (read: written in the last 15 years) has it built in? Why do N wait’s when you can do one? Yada-yada-ya ๐
I believe every junior Unix system admin has written something more sophisticated and portable…
and if the target doesnt consist of multiple independent drives, which are much slower than the source storage, doing parallel operation only increases overhead.
besides:
proxy:~# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Apr 10 02:37 /bin/sh -> dash
this is way better on Linux.
but i think this was more of a tutorial of “This is how it can be done – look at all of the very obvious and well commented code” rather than an attempt to show the most elegant code possible. Also, FWIW, even if /bin/sh isn’t a link to /bin/bash, #!/bin/sh just grabs your default system shell these days – bash, tcsh, whatever – on most *nixes.
> Just make sure you have a sane PATH in your environment.
I don’t actually want my backup script to have a PATH, though it makes the stuff more portable, if u use thing’s that are in /usr/.
But speaking for myself, the stuff in /bin is alright for a backup script, plus the shell-shuilt-ins.
> #!/bin/sh just grabs your default system shell these days – bash, tcsh, whatever – on most *nixes.
/bin/sh sometimes a link to tcsh? You know this would break… well ALOT, and nobody sane would do this.
…but hell that’s what i thought about linking bash to /bin/sh before i noticed more and more Linux distros do that.
/me hates the so called sh compatibility mode in bash, because it’s not and people tend to think it is, thus using sh features, that are infact bash features, all under the sign of:”#!/bin/sh”
I can’t imagine that’s true. I know that if no default is mentioned, and the script is run as a user, the shell should refer to the shell listed in /etc/password, but linking sh to any c shell would be insanity.
That’s what I meant – somehow my confused idiot pre-coffee mind got things jumbled with sh compatibility. Sorry.
Remember, this script is really vulnerability to simply symlink attacks…
Typically backup script is runt by root. If attacker creates symlink /tmp/date.0 -> /etc/shadow (ln -s /etc/shadow /tmp/date.0), he (or she, whatever) can cause nice DoS.