34 |
my $tar_dir = $Conf{InstallDir}.'/'; |
my $tar_dir = $Conf{InstallDir}.'/'; |
35 |
$tar_dir .= $Conf{GzipTempDir} || die "GzipTempDir isn't defined in configuration"; |
$tar_dir .= $Conf{GzipTempDir} || die "GzipTempDir isn't defined in configuration"; |
36 |
|
|
37 |
die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir && -w $tar_dir); |
die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir); |
38 |
|
|
39 |
my $iso_dir = $Conf{InstallDir}.'/'; |
my $iso_dir = $Conf{InstallDir}.'/'; |
40 |
$iso_dir .= $Conf{ISOTempDir} || die "ISOTempDir isn't defined in configuration"; |
$iso_dir .= $Conf{ISOTempDir} || die "ISOTempDir isn't defined in configuration"; |
132 |
my $sth_archive_backup = $dbh->prepare( qq{ |
my $sth_archive_backup = $dbh->prepare( qq{ |
133 |
select |
select |
134 |
backup_id, |
backup_id, |
135 |
|
archive_id, |
136 |
hosts.name as host, |
hosts.name as host, |
137 |
shares.name as share, |
shares.name as share, |
138 |
backups.num as num |
backups.num as num, |
139 |
from archive_backup |
from archive_backup |
140 |
join archive on archive_id = archive.id |
join archive on archive_id = archive.id |
141 |
join backups on backup_id = backups.id |
join backups on backup_id = backups.id |
144 |
where archive.dvd_nr = ? |
where archive.dvd_nr = ? |
145 |
}); |
}); |
146 |
|
|
147 |
|
my $sth_archive_burned = $dbh->prepare( qq{ |
148 |
|
insert into archive_burned |
149 |
|
(archive_id, iso_size) |
150 |
|
values ( (select id from archive where dvd_nr =?), ?) |
151 |
|
}); |
152 |
|
|
153 |
foreach my $arc (@archives_to_burn) { |
foreach my $arc (@archives_to_burn) { |
154 |
exit if ($arc eq ']quit['); |
exit if ($arc eq ']quit['); |
155 |
|
|
162 |
|
|
163 |
print "Working on DVD #$dvd_nr in $tmp_dir\n"; |
print "Working on DVD #$dvd_nr in $tmp_dir\n"; |
164 |
|
|
165 |
my $iso_file = "${iso_dir}/${dvd_nr}.iso"; |
my $list_file = my $iso_file = "${iso_dir}/${dvd_nr}"; |
166 |
|
$list_file .= '.list'; |
167 |
skip "ISO $iso_file allready exists" if (-e $iso_file); |
$iso_file .= '.iso'; |
168 |
|
|
169 |
|
if (-e $iso_file) { |
170 |
|
print "ISO $iso_file allready exists\n"; |
171 |
|
goto BURN; |
172 |
|
} |
173 |
|
|
174 |
$sth_archive_backup->execute($dvd_nr); |
$sth_archive_backup->execute($dvd_nr); |
175 |
|
|
176 |
print "Running mkisofs now...\n"; |
open(my $list, "> $list_file") || skip "can't open $list_file: $!"; |
|
|
|
|
my $cmd = qq{ mkisofs -A BackupPC -gui -J -r -T --input-charset ISO-8859-2 -V $dvd_nr -o $iso_file -path-list - }; |
|
177 |
|
|
178 |
open(my $mkisofs, "| $cmd 2>&1") || skip "can't run $cmd: $!"; |
my $inc = 0; |
179 |
|
|
180 |
while (my $row = $sth_archive_backup->fetchrow_hashref) { |
while (my $row = $sth_archive_backup->fetchrow_hashref) { |
181 |
my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}); |
my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}); |
182 |
skip "can't find increment $tar_file: $!" unless (-r "$tar_dir/$tar_file"); |
skip "can't find increment $tar_file: $!" unless (-r "$tar_dir/$tar_file"); |
183 |
print $mkisofs "$tar_dir/$tar_file\n"; |
print $list "$tar_dir/$tar_file\n"; |
184 |
} |
$inc++; |
185 |
|
|
|
while(! -e $iso_file) { |
|
|
sleep 1; |
|
186 |
} |
} |
187 |
|
|
188 |
print "Created $iso_file in ", fmt_time(time() - $t), "\n"; |
print "Running mkisofs now for $inc increments...\n"; |
189 |
|
|
190 |
|
my $cmd = qq{ mkisofs -A BackupPC -gui -J -r -T --input-charset ISO-8859-2 -V $dvd_nr -o $iso_file -path-list $list_file }; |
191 |
|
|
192 |
|
system($cmd) == 0 or skip "can't run $cmd: $?"; |
193 |
|
|
194 |
|
my $size = (stat($iso_file))[7]; |
195 |
|
|
196 |
|
print "Created $iso_file [$size bytes] in ", fmt_time(time() - $t), "\n"; |
197 |
|
|
198 |
|
BURN: |
199 |
|
# FIXME add call to cdrecord here! |
200 |
|
$sth_archive_burned->execute($dvd_nr, $size); |
201 |
|
print "Media burn for $dvd_nr recorded\n"; |
202 |
|
|
203 |
SKIP: |
SKIP: |
204 |
|
|