minor updates to backup script.

This commit is contained in:
Solomon Peachy 2015-07-07 22:02:41 -04:00
parent 5b6b4b1d17
commit f202f3fc02
1 changed files with 14 additions and 5 deletions

View File

@ -26,10 +26,14 @@ my $dest_dir = "/tmp"; # where we shove the ISO
$block = 2048; # CD/DVD uses 2K blocks
#$max = 700*1024*1024; # 700 MiB, (CD)
#$max = 4700*1000*1000; # 4700 MB, (DVD)
$max = 8500*1000*1000; # 8500 MB, (DVD-9)
$max = 8500*1000*1000; # 8500 MB, (DVD-DL)
#$max = 25000*1000*1000; # 25GB, (Blu-Ray)
#$max = 50000*1000*1000; # 50GB, (Blu-Ray DL)
$max -= 10*1024*1024; # Leave 10MiB free to account for block slop.
my $where = "size = 0"; # only include originals, not scaled versions
my ($dbh, $select, $stmt, $stmt2);
my ($index, $indexfile, $flistfile, @flist, $volume);
@ -42,6 +46,11 @@ $volume = sprintf ("photos-%04d", $index);
$count = 0;
$size = 0;
if ($where) {
$where .= " AND ";
}
$where .= " backup_volume IS NULL ";
# Account for DB backup size
$size += ((stat("$root/$db_backup"))[7] + $block - 1) / $block * $block;
@ -53,8 +62,8 @@ $dbh = DBI->connect("dbi:Pg:$db_dsn",
$dbh->{RaiseError} = 1;
# load it all up from the database!
$stmt = $dbh->prepare("SELECT path, filesize, sha1sum FROM files WHERE backup_volume IS NULL ORDER by path");
$stmt2 = $dbh->prepare("UPDATE files SET backup_volume = ? WHERE path = ?");
$stmt = $dbh->prepare("SELECT identifier, path, filesize, sha1sum FROM files WHERE $where ORDER by path");
$stmt2 = $dbh->prepare("UPDATE files SET backup_volume = ? WHERE identifier = ?");
open (INDEX_FILE, ">$indexfile") || die ("can't open $indexfile for writing");
@ -71,7 +80,7 @@ while (my $href = $stmt->fetchrow_hashref()) {
push (@flist, $$href{"path"});
$size += $filesize;
$count++;
$stmt2->execute($volume, $$href{"path"});
$stmt2->execute($volume, $$href{"identifier"});
} else {
last;
}