#!/usr/bin/perl

#
# decode astaro config files
# usage:
#
# unabf <someconfigfile> | less
#
# Astaro stores its regular config backups in
# /var/confd/var/storage/snapshots/
# as
# cfg_<nnnn>_<seconds-since-epoch>
#
# Those files are perl Storable (v0.7) data (major 2) (minor 7)
#
# If you copy such a config backup file to some astaro host and
# run this command to decode it, it should print the config
# data structure.
#
# TODO: decode should work on non-astaro hardware, but fails
#

use warnings;
use strict;

use Storable;
use Data::Dumper;

if ( $#ARGV == -1 ) {
    print "usage: $0 filename\n";
    exit (1);
}

my($filename) = $ARGV[0];

my($info) = Storable::file_magic( $filename );

print ${$info}{version}."\n";
print ${$info}{byteorder}."\n";

my($hashref) = retrieve($filename);

print Dumper($hashref);

