209 |
$doc->add_attr('@uri', $uri); |
$doc->add_attr('@uri', $uri); |
210 |
|
|
211 |
foreach my $c (@{ $sth->{NAME} }) { |
foreach my $c (@{ $sth->{NAME} }) { |
212 |
$doc->add_attr($c, $row->{$c}) if ($row->{$c}); |
$doc->add_attr($c, $row->{$c}) if (defined($row->{$c})); |
213 |
} |
} |
214 |
|
|
215 |
#$doc->add_attr('@cdate', fmt_date($row->{'date'})); |
#$doc->add_attr('@cdate', fmt_date($row->{'date'})); |
256 |
|
|
257 |
|
|
258 |
## update index ## |
## update index ## |
259 |
if (($opt{i} || $opt{j} || ($index_path && ! -e $index_path)) && !$opt{c}) { |
if (($opt{i} || $opt{j} || ($index_path && ! -e $TopDir . $index_path)) && !$opt{c}) { |
260 |
# update all |
# update all |
261 |
print "force update of HyperEstraier index "; |
print "force update of HyperEstraier index "; |
262 |
print "importing existing data" unless (-e $index_path); |
print "importing existing data" unless (-e $TopDir . $index_path); |
263 |
print "by -i flag" if ($opt{i}); |
print "by -i flag" if ($opt{i}); |
264 |
print "by -j flag" if ($opt{j}); |
print "by -j flag" if ($opt{j}); |
265 |
print "\n"; |
print "\n"; |
310 |
size bigint not null, |
size bigint not null, |
311 |
inc_size bigint not null default -1, |
inc_size bigint not null default -1, |
312 |
inc_deleted boolean default false, |
inc_deleted boolean default false, |
313 |
|
parts integer not null default 1, |
314 |
PRIMARY KEY(id) |
PRIMARY KEY(id) |
315 |
); |
); |
316 |
|
|
343 |
); |
); |
344 |
|
|
345 |
create table archive_burned ( |
create table archive_burned ( |
346 |
archive_id int references archive(id), |
archive_id int references archive(id), |
347 |
date date default now(), |
date timestamp default now(), |
348 |
iso_size int default -1 |
part int not null default 1, |
349 |
|
copy int not null default 1, |
350 |
|
iso_size bigint default -1 |
351 |
); |
); |
352 |
|
|
353 |
|
create table backup_parts ( |
354 |
|
id serial, |
355 |
|
backup_id int references backups(id), |
356 |
|
part_nr int not null check (part_nr > 0), |
357 |
|
tar_size bigint not null check (tar_size > 0), |
358 |
|
size bigint not null check (size > 0), |
359 |
|
md5 text not null, |
360 |
|
items int not null check (items > 0), |
361 |
|
date timestamp default now(), |
362 |
|
primary key(id) |
363 |
|
); |
364 |
}); |
}); |
365 |
|
|
366 |
print "creating indexes: "; |
print "creating indexes: "; |
379 |
files:size |
files:size |
380 |
archive:dvd_nr |
archive:dvd_nr |
381 |
archive_burned:archive_id |
archive_burned:archive_id |
382 |
|
backup_parts:backup_id,part_nr |
383 |
)) { |
)) { |
384 |
do_index($index); |
do_index($index); |
385 |
} |
} |
434 |
|
|
435 |
$sth->{insert_backups} = $dbh->prepare(qq{ |
$sth->{insert_backups} = $dbh->prepare(qq{ |
436 |
INSERT INTO backups (hostID, num, date, type, shareid, size) |
INSERT INTO backups (hostID, num, date, type, shareid, size) |
437 |
VALUES (?,?,?,?,?,?) |
VALUES (?,?,?,?,?,-1) |
438 |
|
}); |
439 |
|
|
440 |
|
$sth->{update_backups_size} = $dbh->prepare(qq{ |
441 |
|
UPDATE backups SET size = ? |
442 |
|
WHERE hostID = ? and num = ? and date = ? and type =? and shareid = ? |
443 |
}); |
}); |
444 |
|
|
445 |
$sth->{insert_files} = $dbh->prepare(qq{ |
$sth->{insert_files} = $dbh->prepare(qq{ |
505 |
# dump some log |
# dump some log |
506 |
print curr_time," ", $share; |
print curr_time," ", $share; |
507 |
|
|
|
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
|
|
|
|
508 |
$sth->{insert_backups}->execute( |
$sth->{insert_backups}->execute( |
509 |
$hostID, |
$hostID, |
510 |
$backupNum, |
$backupNum, |
511 |
$backup->{'endTime'}, |
$backup->{'endTime'}, |
512 |
substr($backup->{'type'},0,4), |
substr($backup->{'type'},0,4), |
513 |
$shareID, |
$shareID, |
514 |
|
); |
515 |
|
|
516 |
|
my ($f, $nf, $d, $nd, $size) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
517 |
|
|
518 |
|
$sth->{update_backups_size}->execute( |
519 |
$size, |
$size, |
520 |
|
$hostID, |
521 |
|
$backupNum, |
522 |
|
$backup->{'endTime'}, |
523 |
|
substr($backup->{'type'},0,4), |
524 |
|
$shareID, |
525 |
); |
); |
526 |
|
|
527 |
print " commit"; |
print " commit"; |
643 |
$filesInBackup->{$path_key}->{'size'} |
$filesInBackup->{$path_key}->{'size'} |
644 |
)); |
)); |
645 |
|
|
646 |
|
# daylight saving time change offset for 1h |
647 |
|
my $dst_offset = 60 * 60; |
648 |
|
|
649 |
|
my $key_dst_prev = join(" ", ( |
650 |
|
$shareID, |
651 |
|
$dir, |
652 |
|
$path_key, |
653 |
|
$filesInBackup->{$path_key}->{'mtime'} - $dst_offset, |
654 |
|
$filesInBackup->{$path_key}->{'size'} |
655 |
|
)); |
656 |
|
|
657 |
|
my $key_dst_next = join(" ", ( |
658 |
|
$shareID, |
659 |
|
$dir, |
660 |
|
$path_key, |
661 |
|
$filesInBackup->{$path_key}->{'mtime'} + $dst_offset, |
662 |
|
$filesInBackup->{$path_key}->{'size'} |
663 |
|
)); |
664 |
|
|
665 |
my $found; |
my $found; |
666 |
if (! defined($beenThere->{$key}) && ! ($found = found_in_db($key, @data)) ) { |
if ( |
667 |
|
! defined($beenThere->{$key}) && |
668 |
|
! defined($beenThere->{$key_dst_prev}) && |
669 |
|
! defined($beenThere->{$key_dst_next}) && |
670 |
|
! ($found = found_in_db($key, @data)) |
671 |
|
) { |
672 |
print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2); |
print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2); |
673 |
|
|
674 |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |
if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) { |