Re: Bash commands
Bob Proulx wrote:
> Russell <email@example.com> [2002-09-01 15:40:58 +1000]:
> > I might have gotten somewhere initially if i hadn't have
> > used those square  brackets.
> A couple of gratuitous comments concerning the scripting plus the
> helpful comments which were posted. I can't help but to say
Thanks for the tips. I'm getting better;)
I've been making this backup script which
is nearly complete:
# Russ' backup
# Warning: Do not run unless you understand every line of this script
# Copy everything (almost) from the system to a backup removeable hard-disk
# run in super-user mode
# the spare hard-disk has enough capacity
# the spare disk has been formatted to match the original
# in number and type of partitions
# The spare disk won't be bootable unless lilo is run separately,
# which i haven't got around to doing yet
# The /boot partition:
# The main root / partition:
# Mount /boot partition
if ! mount | grep -qs /dev/$HDD_BOOT
if ! mount -t ext2 /dev/$HDD_BOOT /mnt
echo "Removeable /dev/$HDD_BOOT not working"
# Copy /boot partition
echo "Updating /boot"
if ! cp -auv /boot /mnt
echo "Failed to update /boot"
# Mount main partition
if ! mount | grep -qs /dev/$HDD_MAIN
if ! mount -t ext2 /dev/$HDD_MAIN /mnt
echo "Removeable $HDD_MAIN not working"
# Copy everything on main partition
# Strip some top level directories we don't want to copy
FILES=$( ls / | sed -e s/boot//g | sed -e s/cdrom//g | sed -e s/proc//g | sed -e s/floppy//g | sed
-e s/mnt//g | sed -e s/dev//g)
# Note: I really want to copy some of these directories and their contents with
# any attributes preserved, but without copying the contents of the files
# (haven't figured out a command for that yet)
for i in $FILES
echo "Updating /$i"
if ! chroot / cp $OPTS $i /mnt
echo "Failed to update /$i"
echo "System backup successful"