[nmglug] Bash Scripting help

Karl Hegbloom karlheg at laclinux.com
Wed Mar 30 14:57:35 PST 2005


On Wed, 2005-03-30 at 12:47 -0800, Tim Emerick wrote:
> I've been working on a bash backup script that runs as a cron job.  To say
> it's inelegant is an understatement at best.  I could use some advice on
> structure and output.
> 
> 1. Rotating backup sets is tedious if I wanted to add or delete the number of
> sets to retain.  Is there a way to loop using a variable?

There is a script called "logrotate" in Debian that does what you want.
"man logrotate" for instructions.  You might also like to try using the
'tob' program, also in Debian.  It makes pretty good backups, and can be
driven by a simple script from cron.  The script I use to run it, named
"/etc/cron.daily/zztob" looks like this:

#!/bin/sh
for VOL in $(cd /etc/tob/volumes && echo *.startdir)
do
  vol=${VOL%%.startdir}
  if [ "$vol" != "example" ]; then
      tob -full $vol
  fi
done

I have 'tob' configured to write backup files to "/var/backups/tob/",
and copy them to another system with 'rsync' from time to time.  This
makes a very redundant backup system that uses a lot more disk space
than is strictly necessary.

I've been told that 'backuppc' is pretty good, and more space efficient.
It's easy to use, and can back up Windows PC's in an office environment.






More information about the nmglug mailing list