Guten Morgen Community,
ich plage mich hier seit ein paar Tagen mit dem Script für die nachträgliche Übertragung der Mail-Anhänge aus der Datenbank raus in einen Ordner.
Meine System-Config: DS713+ im RAID1, DSM 4.3-3827 Update 8.
Ich rufe das Script folgendermassen auf
perl db-convert-attachments-to-files <ysql_user>t <sql_password> <sql_datenbank> /volume1/zarafa_attachments
Darauf erhalte ich die Fehlermeldung:
The size of all attachments in the database is: 2844983296 Bytes (2.65 GB)
Argument "5%" isn't numeric in division (/) at db-convert-attachments-to-files line 18.
Available space is: 5% Bytes (5 B)
Argument "5%" isn't numeric in numeric ge (>=) at db-convert-attachments-to-files line 84.
Not enough space left on device.
Ich habe einige Threads durchgelesen und das Script dementsprechend verändert, aber ich komme nicht weiter.
Hier das Script:
#!/usr/bin/perl -w
use strict;
use DBI;
my $L1 = 10;
my $L2 = 20;
sub do_error($) {
exit(1);
}
sub readable {
my $size = shift;
my @add = qw( B KB MB GB TB );
my $i ;
for ($i = 0; $i < 5;$i++) {
if ( int($size / 1024) > 0 ) {
$size = $size / 1024;
} else {
$size = 0.01*int(0.5+ $size/0.01) . " " . $add[$i];
- db-convert-attachments-to-files 1/137 0%
my $free = `df -P $basepath | tail -1 | awk '{print \$4}'`;
chomp($free);
print "Available space is: " . $free . " Bytes (" . readable($free) . ")\n";
if ( $dbsize >= $free ) {
print "Not enough space left on device.\n";
exit(0);
}
print "Finding all attachments...\n";
$sth = $db->prepare("SELECT distinct(instanceid) FROM lob WHERE tag=0x3701");
$sth->execute() || die $DBI::errstr;;
if ($sth->rows == 0) {
print "No attachments found.\n";
exit(0);
}
print "Processing ".$sth->rows." attachments\n";
while(@row = $sth->fetchrow_array()) {
my @data;
my $path = $basepath."/".($row[0] % $L1)."/".(($row[0] / $L1) % $L2);
my $filename = $path."/".$row[0];
system("mkdir -p ".$path) == 0 or die("Unable to create attachment direc
if ( -s $filename ) {
next;
}
open(AFILE, ">".$filename) or die("Unable to open new attachment file");
my $sth2 = $db->prepare("SELECT val_binary FROM lob WHERE instanceid=".$
$res = $sth2->execute();
if(!$res) {
print " Unable to extract attachment ".$row[0]."\n";
next;
}
while (@data = $sth2->fetchrow_array()) {
print AFILE $data[0] or die("Not all data could be retrieved fro
}
close(AFILE);
}
print "Done.\n";
if (defined($delete) && $delete) {
print "Deleting attachments from database...\n";
$sth = $db->prepare("DELETE FROM lob WHERE tag=0x3701");
$sth->execute() || die $DBI::errstr;
print "Done.\n";
}
print "Remember to correct the ownership of the files for Zarafa to access, when
$db->do("commit;");
ich plage mich hier seit ein paar Tagen mit dem Script für die nachträgliche Übertragung der Mail-Anhänge aus der Datenbank raus in einen Ordner.
Meine System-Config: DS713+ im RAID1, DSM 4.3-3827 Update 8.
Ich rufe das Script folgendermassen auf
perl db-convert-attachments-to-files <ysql_user>t <sql_password> <sql_datenbank> /volume1/zarafa_attachments
Darauf erhalte ich die Fehlermeldung:
The size of all attachments in the database is: 2844983296 Bytes (2.65 GB)
Argument "5%" isn't numeric in division (/) at db-convert-attachments-to-files line 18.
Available space is: 5% Bytes (5 B)
Argument "5%" isn't numeric in numeric ge (>=) at db-convert-attachments-to-files line 84.
Not enough space left on device.
Ich habe einige Threads durchgelesen und das Script dementsprechend verändert, aber ich komme nicht weiter.
Hier das Script:
#!/usr/bin/perl -w
use strict;
use DBI;
my $L1 = 10;
my $L2 = 20;
sub do_error($) {
exit(1);
}
sub readable {
my $size = shift;
my @add = qw( B KB MB GB TB );
my $i ;
for ($i = 0; $i < 5;$i++) {
if ( int($size / 1024) > 0 ) {
$size = $size / 1024;
} else {
$size = 0.01*int(0.5+ $size/0.01) . " " . $add[$i];
- db-convert-attachments-to-files 1/137 0%
my $free = `df -P $basepath | tail -1 | awk '{print \$4}'`;
chomp($free);
print "Available space is: " . $free . " Bytes (" . readable($free) . ")\n";
if ( $dbsize >= $free ) {
print "Not enough space left on device.\n";
exit(0);
}
print "Finding all attachments...\n";
$sth = $db->prepare("SELECT distinct(instanceid) FROM lob WHERE tag=0x3701");
$sth->execute() || die $DBI::errstr;;
if ($sth->rows == 0) {
print "No attachments found.\n";
exit(0);
}
print "Processing ".$sth->rows." attachments\n";
while(@row = $sth->fetchrow_array()) {
my @data;
my $path = $basepath."/".($row[0] % $L1)."/".(($row[0] / $L1) % $L2);
my $filename = $path."/".$row[0];
system("mkdir -p ".$path) == 0 or die("Unable to create attachment direc
if ( -s $filename ) {
next;
}
open(AFILE, ">".$filename) or die("Unable to open new attachment file");
my $sth2 = $db->prepare("SELECT val_binary FROM lob WHERE instanceid=".$
$res = $sth2->execute();
if(!$res) {
print " Unable to extract attachment ".$row[0]."\n";
next;
}
while (@data = $sth2->fetchrow_array()) {
print AFILE $data[0] or die("Not all data could be retrieved fro
}
close(AFILE);
}
print "Done.\n";
if (defined($delete) && $delete) {
print "Deleting attachments from database...\n";
$sth = $db->prepare("DELETE FROM lob WHERE tag=0x3701");
$sth->execute() || die $DBI::errstr;
print "Done.\n";
}
print "Remember to correct the ownership of the files for Zarafa to access, when
$db->do("commit;");