Restoring items only till a specific date (zarafa-restore)
From Zarafa wiki
(New page: == Description == This is a modified version of the readable-index.pl you find located in /usr/share/zarafa/zarafa-backup-helpers/readable-index.pl. It enables you to restore items only ti...) |
m |
||
| Line 12: | Line 12: | ||
| - | == | + | == Script == |
#!/usr/bin/env perl | #!/usr/bin/env perl | ||
Revision as of 11:51, 3 September 2009
Contents |
Description
This is a modified version of the readable-index.pl you find located in /usr/share/zarafa/zarafa-backup-helpers/readable-index.pl. It enables you to restore items only till a specific date, e.g. only items till 09/12/31.
In addition to the original readable-index.pl you now have the ability to pass a linux timestap as a secound parameter. The output of the script can be piped into a file that can be used by zarafa-restore.
Usage
~# readable-index.pl username unitxtimestamp > username.restore.txt ~# zarafa-restore -u username -f username -i username.restore.txt -v
Script
#!/usr/bin/env perl
use strict;
if (scalar(@ARGV) < 1) {
print "You must pass 1 index filename and optional 1 unix timestamp.\n";
exit 1;
}
open(IDX,$ARGV[0]) or die("Unable to open index file ".$ARGV[0]);
my $version = <IDX>;
if ($version =~ /^R/) {
$version = 1;
} elsif ($version =~ /^V:([0-9]+)/) {
$version = $1;
} else {
print "Unknown index version.\n";
close(IDX);
exit(1);
}
if ($version == 1) {
print "RestoreKey\tType\tDate\t\t\t\tItem\t\tName\n";
} else {
if (scalar(@ARGV) < 2) {
print "RestoreKey\tType\tDate\t\t\t\tItem\t\tExtra\t\tName\n";
}
}
while (<IDX>) {
my @items = split(/:/, $_);
my ($end);
my ($type, $rk, $date, $itype, $inc, $name, $extra, $unixts);
if ($items[0] =~ /^C/) {
$type = "Folder";
$rk = $items[6];
$date = localtime($items[8]);
$unixts = $items[8];
$itype = $items[9];
splice(@items, 0, 10);
} elsif ($items[0] =~ /^M/) {
$type = "Message";
$rk = $items[4];
$date = localtime($items[5]);
$unixts = $items[5];
$itype = $items[6];
if ($version == 2) {
if ($itype eq "IPM.Appointment") {
$extra = localtime($items[9])."\t".localtime($items[10]);
$end = 11;
} elsif ($itype eq "IPM.Task") {
$extra = localtime($items[9]);
$end = 10;
} elsif ($itype eq "IPM.StickyNote" || $itype eq "IPM.Note" || $itype eq "IPM.Contact") {
$extra = $items[9];
$end = 10;
} else {
$extra = "";
$end = 9;
}
} else {
# set to null
$end = 8;
}
splice(@items, 0, $end);
} else {
next;
}
$name = join(':', @items);
if (scalar(@ARGV) == 1) {
my $line = join("\t",($rk,$type,$date,$itype,$extra,$name));
print $line;
} else {
if ($unixts <= $ARGV[1]) {
print "$rk\n";
}
}
}
close(IDX);
Thanks
Credit and Thanks go to Marco Gabriel of the inett GmbH (http://www.inett.de/) for letting us use the script in the Wiki.
Links
German blog-post of the inett GmbH http://www.inett.de/blog/archives/27-zarafa-restore-nur-bis-zu-einem-bestimmten-Datum.html
Converting a date into a Unix timestamp http://www.aritso.net/aritso-tools/timestampconverter/