I've been meaning to post this for a while, but ever time I think of it, I'm at home and I can't get to this script--incompatibility with Snow Leopard and our network.
The trick that made this script useful for me (and saved me from having tor really think outside of the box) was basename
I know I need to comment this script so they know who to come sue when it doesn't work and actually explain what the hell is going on here, but I wanted to hear from my *nix versed readers.
I'm also considering x-posting to
unixadmin for recommendations on how to clean up the script or what kind of things I should add. For instance, a suggestion was made to check for 0 byte files. Also, it seems like on the day, just echo didn't produce a blank line. I considered echo \n but I didn't think that would work either.
Nevertheless, here's my latest script made public for review, critique and criticism.
#! /bin/bash
for x in `ls |grep backup`
do
echo Creating DB `basename $x .backup`
createdb -E SQL-ASCII -O libsoft `basename $x .backup`
echo restoring `basename $x .backup`
pg_restore --no-owner -d `basename $x .backup` $x
echo NEXT
done