re-implement only_increment by comparing inodes
[BackupPC.git] / bin / BackupPC_attribPrint
1 #!/usr/bin/perl
2 #============================================================= -*-perl-*-
3 #
4 # BackupPC_attribPrint: print the contents of attrib files.
5 #
6 # DESCRIPTION
7 #  
8 #   Usage: BackupPC_attribPrint attribPath
9 #
10 #   Compression status of attrib path is based on $Conf{CompressLevel}.
11 #
12 # AUTHOR
13 #   Craig Barratt  <cbarratt@users.sourceforge.net>
14 #
15 # COPYRIGHT
16 #   Copyright (C) 2005-2009  Craig Barratt
17 #
18 #   This program is free software; you can redistribute it and/or modify
19 #   it under the terms of the GNU General Public License as published by
20 #   the Free Software Foundation; either version 2 of the License, or
21 #   (at your option) any later version.
22 #
23 #   This program is distributed in the hope that it will be useful,
24 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
25 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 #   GNU General Public License for more details.
27 #
28 #   You should have received a copy of the GNU General Public License
29 #   along with this program; if not, write to the Free Software
30 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31 #
32 #========================================================================
33 #
34 # Version 3.2.0, released 31 Jul 2010.
35 #
36 # See http://backuppc.sourceforge.net.
37 #
38 #========================================================================
39
40 use strict;
41 no  utf8;
42 use lib "/usr/local/BackupPC/lib";
43
44 use BackupPC::Lib;
45 use BackupPC::Attrib qw(:all);
46 use BackupPC::FileZIO;
47 use Data::Dumper;
48
49 die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
50 my $TopDir = $bpc->TopDir();
51 my $BinDir = $bpc->BinDir();
52 my %Conf   = $bpc->Conf();
53
54 if ( @ARGV != 1 ) {
55     print STDERR "Usage: $0 attribPath\n";
56     exit(1);
57 }
58 if ( !-f $ARGV[0] ) {
59     print STDERR "$ARGV[0] does not exist\n";
60     exit(1);
61 }
62
63 my $attrib = BackupPC::Attrib->new({ compress => $Conf{CompressLevel} });
64
65 my($dir, $file);
66
67 if ( $ARGV[0] =~ m{(.+)/(.+)} ) {
68     $dir  = $1;
69     $file = $2;
70 } else {
71     $dir = $ARGV[0];
72 }
73
74 if ( !$attrib->read($dir, $file) ) {
75     print STDERR "Cannot read attrib file $ARGV[0]\n";
76     exit(1);
77 }
78 my $info = $attrib->get();
79 $Data::Dumper::Indent = 1;
80 print Dumper($info);