How to unzip backup files of RaQ4 server?


A

Andy Signer

Hi,
tonight I was searching for a script to extract *.raq files. I wasn't
able to get one on the inet. The only thing I found was the script
written by Jeff Bilicki for RaQ2. I customised it for RaQ 4. May it be
helpful to others.

Here it comes (quick 'n dirty)!

Have fun ;-)
Andy


#!/usr/bin/perl
# Andy Signer <blackhole at diediedie.org>
# removes the header out of a RaQ 4 backup file (*.raq) and write a
# normal tar.gz archive
#
# Original version by:
# Jeff Bilicki <jeffb at cobaltnet.com>
# removes the header out of a RaQ 2 backup file
###############################################################################
use strict;

my $infile;
my $outfile = "out.tar.gz";
my $header_start ="\%\%BACKUP_HEADER";
my $header_end = "\%\%END_XML";

if (@ARGV) {
$infile = $ARGV[0];
} else {
print "usage: stripheader.pl <file name>\n";
exit 1;
}

open (INFILE, $infile) or die "Can't open: $!\n";
open (OUTFILE, ">$outfile") or die "Can't open $!\n";

while (<INFILE>) {
if ( /^$header_start/ ... /^$header_end/ ) {
next;
}
print OUTFILE $_;
}

close(INFILE);
close(OUTFILE);
exit 0;
 
Ad

Advertisements

J

Joe Smith

Andy said:
my $infile;
my $outfile = "out.tar.gz";
my $header_start ="\%\%BACKUP_HEADER";
my $header_end = "\%\%END_XML";

if (@ARGV) {
$infile = $ARGV[0];
} else {
print "usage: stripheader.pl <file name>\n";
exit 1;
}

open (INFILE, $infile) or die "Can't open: $!\n";
open (OUTFILE, ">$outfile") or die "Can't open $!\n";

while (<INFILE>) {
if ( /^$header_start/ ... /^$header_end/ ) {
next;
}
print OUTFILE $_;
}

close(INFILE);
close(OUTFILE);
exit 0;

That can be made a lot shorter.
-Joe

use constant OUTFILENAME => 'out.tar.gz';
my $header_start = '%%BACKUP_HEADER';
my $header_end = '%%END_XML';
die "Usage: $0 inputfile\n" unless @ARGV;
open OUT,'>',OUTFILENAME or die "Cannot create ",OUTFILENAME,": $!\n";
while (<>) {
print OUT unless /^$header_start/ ... /$header_end/;
}
close OUT or warn "Possible truncation on output file: $!\n";
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top