I frequently use the following Bash shell function to allow me to locate and
read pool/cpool files as I got tired of manually converting to the
pool heirarchy decoding. It's not very complicated, but helpful

1. You can enter either:
   - 32 hex character digest (lower case): <32hex>
   - attrib file name with/without preceding path and either in the
     "normal" or inode form. i.e..
        [<path>/]attrib_<32hex>
        [<path>/]attrib<2hex>_<32hex>

2. It works with pool or cpool
3. It works with v3/v4

#####################################################################################
function BackupPC_zcatPool ()
{
    local BACKUPPC_ZCAT=$(which BackupPC_zcat)
    [ -n "$BACKUPPC_ZCAT" ] || 
BACKUPPC_ZCAT=/usr/share/backuppc/bin/BackupPC_zcat
    [ -n "$CPOOL" ] || local CPOOL=/var/lib/backuppc/cpool
    [ -n "$POOL" ] || local POOL=/var/lib/backuppc/pool

    local file=${1##*/} #Strip the path prefix
    #If attrib file...
    file=${file/attrib[0-9a-f][0-9a-f]_/attrib_} #Convert inode format attrib 
to normal attrib
    file=${file##attrib_} #Extract the md5sum from the attrib file name

    local ABCD=$(printf '%x' "$(( 0x${file:0:4} & 0xfefe ))")
    local prefix="${ABCD:0:2}/${ABCD:2:2}"
#   echo $prefix

    if [ -e "$CPOOL/$prefix/$file" ]; then #V4 - cpool
        $BACKUPPC_ZCAT $CPOOL/$prefix/$file
    elif [ -e "$POOL/$prefix/$file" ]; then #V4 - pool
        cat $CPOOL/$prefix/$file
    elif [ -e "$CPOOL/${file:0:1}/${file:1:1}/${file:2:1}/$file" ]; then #V3 - 
cpool
        $BACKUPPC_ZCAT "$CPOOL/${file:0:1}/${file:1:1}/${file:2:1}/$file"
    elif [ -e "$POOL/${file:0:1}/${file:1:1}/${file:2:1}/$file" ]; then #V3 - 
pool
        cat "$POOL/${file:0:1}/${file:1:1}/${file:2:1}/$file"
    else
        echo "Can't find pool file: $file" >/dev/stderr
    fi
}


_______________________________________________
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

Reply via email to