55 |
return strftime($t_fmt,localtime()); |
return strftime($t_fmt,localtime()); |
56 |
} |
} |
57 |
|
|
58 |
|
sub dumpArchive2XML($$$) |
59 |
|
{ |
60 |
|
my ($dbh, $dvd_nr, $filename) = @_; |
61 |
|
my %archive; |
62 |
|
my $output = new IO::File(">$filename"); |
63 |
|
my $writer = new XML::Writer(OUTPUT=>$output, NEWLINES => 1); |
64 |
|
|
65 |
|
my $files_sql = q{ |
66 |
|
SELECT |
67 |
|
files.path AS path, |
68 |
|
files.date AS date, |
69 |
|
files.type AS type, |
70 |
|
files.size AS size |
71 |
|
FROM files, backups, shares |
72 |
|
WHERE files.backupnum=backups.num AND |
73 |
|
files.shareid=shares.id AND |
74 |
|
shares.hostid=backups.hostid AND |
75 |
|
backups.id=? |
76 |
|
}; |
77 |
|
|
78 |
|
my $backups_sql = q{ |
79 |
|
SELECT |
80 |
|
backups.id AS backup_id, |
81 |
|
hosts.name AS host, |
82 |
|
backups.num AS num, |
83 |
|
backups.date AS date, |
84 |
|
shares.name AS share, |
85 |
|
backups.size AS backup_size, |
86 |
|
backups.inc_size AS compress_size |
87 |
|
FROM backups, archive_backup, hosts, shares |
88 |
|
WHERE archive_backup.backup_id = backups.id |
89 |
|
AND hosts.id=backups.hostid |
90 |
|
AND shares.id=backups.shareid |
91 |
|
AND archive_backup.archive_id = ? |
92 |
|
}; |
93 |
|
|
94 |
|
my $sth = $dbh->prepare("SELECT dvd_nr, total_size, note, username, date,id FROM archive WHERE dvd_nr=?"); |
95 |
|
$sth->execute($dvd_nr); |
96 |
|
my $row = $sth->fetchrow_hashref(); |
97 |
|
|
98 |
|
my $row_h; |
99 |
|
foreach my $hide (qw/id note/) { |
100 |
|
$row_h->{$hide} = $row->{$hide} || die "no $hide"; |
101 |
|
delete $row->{$hide}; |
102 |
|
} |
103 |
|
|
104 |
|
$writer->startTag("archive", %{$row}); |
105 |
|
|
106 |
|
$writer->startTag("note"); |
107 |
|
$writer->characters( $row_h->{'note'} ); |
108 |
|
$writer->endTag("note"); |
109 |
|
|
110 |
|
my $sth_backups = $dbh->prepare( $backups_sql ); |
111 |
|
$sth_backups->execute( $row_h->{'id'} ); |
112 |
|
|
113 |
|
while (my $row = $sth_backups->fetchrow_hashref()) { |
114 |
|
|
115 |
|
my $sth_files = $dbh->prepare( $files_sql); |
116 |
|
$sth_files->execute($row->{'backup_id'}); |
117 |
|
|
118 |
|
delete($row->{'backup_id'}); |
119 |
|
|
120 |
|
$writer->startTag( "backup", %{$row} ); |
121 |
|
|
122 |
|
while (my $row = $sth_files->fetchrow_hashref()) { |
123 |
|
# convert filetype to string |
124 |
|
$row->{'type'} = BackupPC::Attrib::fileType2Text(undef, $row->{'type'}); |
125 |
|
my $path = $row->{'path'}; delete $row->{'path'}; |
126 |
|
|
127 |
|
$writer->startTag("file", %{$row}); |
128 |
|
$writer->characters( $path ); |
129 |
|
$writer->endTag("file"); |
130 |
|
} |
131 |
|
$writer->endTag("backup"); |
132 |
|
} |
133 |
|
|
134 |
|
$writer->endTag("archive"); |
135 |
|
$writer->end(); |
136 |
|
|
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
#----- main |
#----- main |
142 |
|
|
143 |
my $sth = $dbh->prepare( qq{ |
my $sth = $dbh->prepare( qq{ |
245 |
|
|
246 |
print "Working on DVD #$dvd_nr in $tmp_dir\n"; |
print "Working on DVD #$dvd_nr in $tmp_dir\n"; |
247 |
|
|
248 |
my $list_file = my $iso_file = "${iso_dir}/${dvd_nr}"; |
my $list_file = my $iso_file = my $xml_file = "${iso_dir}/${dvd_nr}"; |
249 |
$list_file .= '.list'; |
$list_file .= '.list'; |
250 |
$iso_file .= '.iso'; |
$iso_file .= '.iso'; |
251 |
|
$xml_file .= '.xml'; |
252 |
|
|
253 |
if (-e $iso_file) { |
if (-e $iso_file) { |
254 |
print "ISO $iso_file allready exists\n"; |
print "ISO $iso_file allready exists\n"; |
271 |
|
|
272 |
# FIXME add file list in xml and txt and note file |
# FIXME add file list in xml and txt and note file |
273 |
|
|
274 |
|
dumpArchive2XML($dbh, $dvd_nr, $xml_file); |
275 |
|
print $list "$xml_file\n"; |
276 |
|
|
277 |
close($list); |
close($list); |
278 |
|
|
279 |
print "Running mkisofs now for $inc increments...\n"; |
print "Running mkisofs now for $inc increments...\n"; |