All pastes #374630 Raw Edit

Someone

public text v1 · immutable
#374630 ·published 2007-02-27 18:53 UTC
rendered paste body
#!/bin/bash

BACKUPLISTFILE=/local/backups/remotebackuplist

BACKUPDISKS="garibaldi:/home neelix:/home garibaldi:/var garibaldi:/local/vidsgallery garibaldi:/local/c garibaldi:/boot garibaldi:/ neelix:/ neelix:/usr garibaldi:/local/scratch/rhbak garibaldi:/root.old neelix:/local/rpms garibaldi:/home/jlarmour/jlarmour.old"
BACKUPLEV1PLUS="garibaldi:/var"

cd /local/backups/amanda || exit 1
cp /dev/null $BACKUPLISTFILE
# Convert slashes to underscores and substitute 'friendly' hostnames with what amanda uses in disk names
BACKUPDISKS=`echo $BACKUPDISKS | sed 's@/@_@g; s@garibaldi:@localhost\.@g; s@neelix:@neelix\.jifvik\.org\.@g'`
BACKUPLEV1PLUS=`echo $BACKUPLEV1PLUS | sed 's@/@_@g; s@garibaldi:@localhost\.@g; s@neelix:@neelix\.jifvik\.org\.@g'`

for disk in $BACKUPDISKS ; do

    # Find the most recent backup at any level
    most_recent=""
    most_recent_lev=0
    for f in `find /local/backups/amanda -name \*.$disk.? -print` ; do
        if [ \( x"$f" = x \) -o \( "$f" -nt "$most_recent" \) ]; then
            most_recent=$f
            most_recent_lev=`echo $f | sed 's@.*\.@@g'`
        fi
    done

    # But if we only want level 0s, just stomp on most_recent_lev instead
    # kludgy but should do
    for i in $BACKUPLEV1PLUS ; do
        if [ x"$i" != x"$disk" ]; then
            most_recent_lev=0
            break;
        fi
    done

    for ((level=0; $level <= $most_recent_lev; level++)) ; do
        newest_at_this_lev=""
        for f in `find /local/backups/amanda -name \*.$disk.$level -print` ; do
            if [ \( x"$newest_at_this_lev" = x \) -o \( "$f" -nt "$newest_at_this_lev" \) ]; then
                newest_at_this_lev=$f
            fi
        done
        if [ x"$newest_at_this_lev" != x ]; then
            REMOTEFNAME=`echo $newest_at_this_lev | sed 's@^.*tape.../data/.....\.\(.*\)@\1@'`
            echo $newest_at_this_lev $REMOTEFNAME >> $BACKUPLISTFILE
        fi
    done
done