95 |
num INTEGER NOT NULL, |
num INTEGER NOT NULL, |
96 |
date integer NOT NULL, |
date integer NOT NULL, |
97 |
type CHAR(4) not null, |
type CHAR(4) not null, |
98 |
PRIMARY KEY(hostID, num) |
shareID integer not null references shares(id), |
99 |
|
PRIMARY KEY(hostID, num, shareID) |
100 |
); |
); |
101 |
}); |
}); |
102 |
|
|
103 |
do_index('backups_hostid,num_unique'); |
#do_index('backups_hostid,num_unique'); |
104 |
|
|
105 |
$dbh->do(qq{ |
$dbh->do(qq{ |
106 |
create table dvds ( |
create table dvds ( |
181 |
SELECT ID FROM hosts WHERE name=? |
SELECT ID FROM hosts WHERE name=? |
182 |
}); |
}); |
183 |
|
|
184 |
$sth->{backups_broj} = $dbh->prepare(qq{ |
$sth->{backups_count} = $dbh->prepare(qq{ |
185 |
SELECT COUNT(*) |
SELECT COUNT(*) |
186 |
FROM backups |
FROM backups |
187 |
WHERE hostID=? AND num=? |
WHERE hostID=? AND num=? AND shareid=? |
188 |
}); |
}); |
189 |
|
|
190 |
$sth->{insert_backups} = $dbh->prepare(qq{ |
$sth->{insert_backups} = $dbh->prepare(qq{ |
191 |
INSERT INTO backups (hostID, num, date, type) |
INSERT INTO backups (hostID, num, date, type, shareid) |
192 |
VALUES (?,?,?,?) |
VALUES (?,?,?,?,?) |
193 |
}); |
}); |
194 |
|
|
195 |
$sth->{insert_files} = $dbh->prepare(qq{ |
$sth->{insert_files} = $dbh->prepare(qq{ |
247 |
fmt_time($backup->{endTime} - $backup->{startTime}), |
fmt_time($backup->{endTime} - $backup->{startTime}), |
248 |
")\n"; |
")\n"; |
249 |
|
|
|
$sth->{backups_broj}->execute($hostID, $backupNum); |
|
|
my ($broj) = $sth->{backups_broj}->fetchrow_array(); |
|
|
next if ($broj > 0); |
|
|
|
|
|
$sth->{insert_backups}->execute( |
|
|
$hostID, |
|
|
$backupNum, |
|
|
$backup->{'endTime'}, |
|
|
$backup->{'type'} |
|
|
); |
|
|
$dbh->commit(); |
|
|
|
|
250 |
my $files = BackupPC::View->new($bpc, $hostname, \@backups, 1); |
my $files = BackupPC::View->new($bpc, $hostname, \@backups, 1); |
251 |
foreach my $share ($files->shareList($backupNum)) { |
foreach my $share ($files->shareList($backupNum)) { |
252 |
|
|
253 |
my $t = time(); |
my $t = time(); |
254 |
|
|
|
print strftime($t_fmt,localtime())," ", $share; |
|
255 |
$shareID = getShareID($share, $hostID, $hostname); |
$shareID = getShareID($share, $hostID, $hostname); |
256 |
|
|
257 |
|
$sth->{backups_count}->execute($hostID, $backupNum, $shareID); |
258 |
|
my ($count) = $sth->{backups_count}->fetchrow_array(); |
259 |
|
# skip if allready in database! |
260 |
|
next if ($count > 0); |
261 |
|
|
262 |
|
# dump some log |
263 |
|
print strftime($t_fmt,localtime())," ", $share; |
264 |
|
|
265 |
my ($f, $nf, $d, $nd) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
my ($f, $nf, $d, $nd) = recurseDir($bpc, $hostname, $files, $backupNum, $share, "", $shareID); |
266 |
|
|
267 |
|
$sth->{insert_backups}->execute( |
268 |
|
$hostID, |
269 |
|
$backupNum, |
270 |
|
$backup->{'endTime'}, |
271 |
|
$backup->{'type'}, |
272 |
|
$shareID |
273 |
|
); |
274 |
|
|
275 |
|
print " commit"; |
276 |
|
$dbh->commit(); |
277 |
|
|
278 |
my $dur = (time() - $t) || 1; |
my $dur = (time() - $t) || 1; |
279 |
printf(" %d/%d files %d/%d dirs [%.2f/s dur: %s]\n", |
printf(" %d/%d files %d/%d dirs [%.2f/s dur: %s]\n", |
280 |
$nf, $f, $nd, $d, |
$nf, $f, $nd, $d, |
281 |
( ($f+$d) / $dur ), |
( ($f+$d) / $dur ), |
282 |
fmt_time($dur) |
fmt_time($dur) |
283 |
); |
); |
|
$dbh->commit(); |
|
284 |
} |
} |
285 |
|
|
286 |
} |
} |