Scott Robinson (quadhome) wrote,
Scott Robinson

Bytebros and Bash Scripting!

More Bytebros work was done today. I locked down all the rounding issues in our reports and changed the data levels display. I’m waiting for Joe to contact me about some craziness in the pair length calculations.

For the low cost of 30 minutes of re-learning bash, I wrote a script that splits Tranzoa monthly backup trees into two DVD-Rs. It has sanity checking, runs in low memory and low hard drive environments, and is extremely simple to use:

scott@tara:~/rsync$ [0] ./ month-tree
Please insert Disk 2 and press and key to continue. [Enter]

I have no idea how I would have gotten this done in Windows.

scott@tara:~/rsync$ [0] cat

clean_temp_files ()
    # Clean up after ourselves.

    rm -f bsh.d1.path bsh.d2.path bsh.dall.path bsh.dmerge.path
    rm -f bsh.d1.pathlist bsh.d2.pathlist

# Generate the pathlists.

echo “$0: Generating pathlists...”

burndir=‘basename $1’

./d1-gen $burndir > bsh.d1.path
./d2-gen $burndir > bsh.d2.path
./dall-gen $burndir | sort > bsh.dall.path

# Sanity check to ensure all directories are obtain.

echo “$0: Performing pathlist sanity check.”

cat bsh.d1.path bsh.d2.path | sort > bsh.dmerge.path

if ! (diff -q bsh.dall.path bsh.dmerge.path); then
    echo “$0: Mismatched path lists. Aborting!”

# Print the sizes of both images.

echo “$0: Disk 1 (Most):” ‘cat bsh.d1.path | xargs du -Hsc | grep total’
echo “$0: Disk 2 (Biggies):” ‘cat bsh.d2.path | xargs du -Hsc | grep total’

# Process the pathlist files with grafts.

echo “$0: Generating graft lists...”

cat bsh.d1.path | xargs -i echo {}={} > bsh.d1.pathlist
cat bsh.d2.path | xargs -i echo {}={} > bsh.d2.pathlist

# Perform dry-runs to check it will all work.

echo “$0: Performing dry-runs...”

volid=‘date -f $burndir/date.txt +%F’
growcmd=“growisofs -dvd-compat -Z $cddev”
mkisofsopts=“-r -J -joliet-long -graft-points -q -V $volid”

if ! ($growcmd -dry-run ${mkisofsopts}-1 -path-list bsh.d1.pathlist); then
    echo “$0: Disk 1 dry-run failed. Aborting!”

if ! ($growcmd -dry-run ${mkisofsopts}-2 -path-list bsh.d2.pathlist); then
    echo “$0: Disk 2 dry-run failed. Aborting!”

# Start the burn cycle!

echo “$0: Starting burn cycle.”

if ! ($growcmd ${mkisofsopts}-1 -path-list bsh.d1.pathlist); then
    echo “$0: Disk 1 burn failed. Aborting!”

eject $cddev

read -p “Please insert Disk 2 and press any key to continue.”
if ! ($growcmd ${mkisofsopts}-2 -path-list bsh.d2.pathlist); then
    echo “$0: Disk 2 burn failed. Aborting!”

eject $cddev


scott@tara:~/rsync$ [0] cat d1-gen

find $1 -maxdepth 2 \( \( -path “$1/backup/mozilla” -o -path “$1/backup/private” -o -path “$1/backup/tzpalm” \) -prune \) -o \( -path $1/backup -o -path “$1/backup/*” -prune -print \) -o \( -path “$1/*” -prune -print \)

scott@tara:~/rsync$ [0] cat d2-gen

find $1 -maxdepth 2 \( -path “$1/backup/mozilla” -o -path “$1/backup/private” -o -path “$1/backup/tzpalm” \) -prune -a -print

scott@tara:~/rsync$ [0] cat dall-gen

find $1 -maxdepth 2 \( -path $1/backup -o -path “$1/backup/*” -prune -print \) -o \( -path “$1/*” -prune -print \)

scott@tara:~/rsync$ [0]
Tags: pretentious

  • Why Is My House Never Clean?

    It’s fun to think about behavior in terms of control systems. Considering enthusiasm this way gives an orderly model for what feels like irrational…

  • I think it's official

    From: Scott Robinson (DRSR) Sent: Monday, February 09, 2009 2:13 PM To: William Lees; Management Modeling Studio Team Subject: RE:…

  • Platonic sleeping buddy for one semester. - m4w

    For posterity’s sake: I can only graduate with your help! Why did I sign-up for a 9AM class? I own a shirt that says I’d never register for one…

  • Post a new comment


    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.