[clue-tech] Multiple system backups

David L. Anselmi anselmi at anselmi.us
Sat Feb 11 19:17:18 MST 2006


William wrote:
[...]
> I revisited the question and wrote a whole new shell script for 
> automated backups that is generally useful and, I believe, portable.  If 
> nothing else, it is pretty robust for my first attempt at a good shell 
> script.  I've decided to publish it and share.  :)
> 
> Details are at:  http://www.kimballstuff.com/projects/nix/
> 
> Feedback is welcome.

Here you go, in no particular order.  All of this is based on my 
preference and experience so don't take it as criticism but just 
something to think about before you revise the script next time.

Rather than define a variable to keep the path for every command you 
call, I would set the $PATH at the beginning and just call the commands. 
  If you insist on a variable for every command, don't call it FOO_PATH, 
just call if FOO.  It's a command, not a path.

You frequently say "delimited list".  Since you mean "whitespace 
delimited list" I would just say "list".

Debian doesn't have a service command for starting/stopping services, at 
least not on a typical system.

Keeping a version and history for each function seems excessive. 
Comments are nice but that stuff belongs in CVS or your changelog.

There's a lot of string manipulation going on.  You should see whether 
perl would be a better choice.

Use install -d rather than writing makedirs().  Probably mkdir -p would 
work too.

Looking through main(), you don't actually do much error checking. 
You'll exit if the backup list, tar file, or compressed tar file don't 
exist.  But you don't check whether the tar command works, or the 
compression command.  For other errors you'll exit 0.  What if samba 
doesn't work or a service won't stop or start?

It may be ok to continue but you might want to feed back that something 
wasn't right, so the user can do something about it.  For example, I 
have a script that logs to a file and if anything goes wrong cron will 
mail me the file.  Even if I wrap your script so cron doesn't mail me 
every time it runs, I can't tell whether I care about the output or not.

Your comments in main() could use improving.  "Perform the backup" isnt' 
nearly as helpful as stating what to do if there are problems.  In the 
places you've decided to continue, why is that the right thing to do?

Dave
_______________________________________________
CLUE-tech mailing list
CLUE-tech at cluedenver.org
http://cluedenver.org/mailman/listinfo/clue-tech



More information about the clue-tech mailing list