#!/usr/bin/perl
#
#  Copyright (c) Source RH <contact@source-rh.com>, All rights reserved.
#  version $Revision: 1521 $
#  date    $LastChangedDate: 2010-10-27 11:07:06 +0200 (mer. 27 oct. 2010) $
#  author  $LastChangedBy: jerome.despatis $
#

use strict;
use warnings;
use lib '/usr/share/backuppc/lib'; # Debian like; change to fit your needs
use BackupPC::Lib;
use JSON;

if (@ARGV != 1)
{
        print "Usage: $0 <hostname>\n";
        exit(1);
}
my $bpc = new BackupPC::Lib;
if (!$bpc)
{
        print "Can't create BackupPC object!\n";
        exit(2);
}
my @Backups = $bpc->BackupInfoRead($ARGV[0]);
print encode_json(\@Backups);
exit(0);