Carlos Collart wrote:
the CSV only contain username,gecos, and clear text password.
i need to build the pw_passwd
<http://localhost/phpmyadmin/sql.php?db=vpopmail&table=aduanett_hn&server=2&token=c46d27c471e70da8bd9cd1cca0758e35&sql_query=SELECT+%2AFROM+%60aduanett_hn%60++ORDER+BY+%60aduanett_hn%60.%60pw_passwd%60+ASC>
I hope you don't have many users :)
Invest in a little time now running a mysqldump, attached is what I run
*hourly*
just replace the hostnames, database names and password and whatever
else thats mine with yours, and make sure the perms are 700 since you
need to include the mysql root pass in it (assuming your roots mysql
pass is set)
It uses sys::syslog and mail::sendmail perl mods as well for notification
Cheers
On 10/1/07, *Quey* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Rick Widmer wrote:
> Carlos Collart wrote:
>> I am the dumbest person alive, and in charge of a vpopmail server,
>> I manage to drop database vpopmail
>
> Not good... Before you do anything else it might be wise to stop
> qmail, and all qmail-smtp processes then back up the mail store.
>
>> the system was a production one, under the domain
xx_at_aduanett_dot_hn
>> I have a backup with the username, name, password in a CVS format
>
> Just one domain, or many?
>
>
>> how could i re-poblate the mysql directly?
>> insert values(xxx,hash(xxx),xx,xx) into 'aduanett.hn
<http://aduanett.hn>
>> < http://aduanett.hn>'.vpopmail or crypt?
>
> This may be the easiest method available. You will have to write a
> Perl, php or whatever program to populate the database. The
password
> hash method depends on your ./configure options. It is pretty easy
> unless you have to track down hashed directories.
>
>
He could use mysql itself, depending on making sure the fields are in
the right order, and one user per line
mysql, use database vpopmail, then :
LOAD DATA INFILE '/path/to/FILENAME.CSV' INTO TABLE vpopmail FIELDS
TERMINATED BY ',' LINES TERMINATED BY '\n';
--
atte.
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
http://www.danasoft.com/sig/CarlosCollart.jpg
<http://www.danasoft.com/sig/CarlosCollart.jpg>
#!/usr/bin/perl -w
use Sys::Syslog;
use Mail::Sendmail;
$HRFILE = `date +'%u.%H'`;
chomp($HRFILE);
$SIG{ALRM} = \&Timeout;
sub Timeout {
&DTBFail(RetryTimeOut);
kill('HUP', -$$);
`rm -f "/var/tmp/.sqlhr"`;
exit(1);
}
if (-e "/var/tmp/.sqlhr") {
&DTBFail(LCK);
print "waiting for sql lockfile to go away...\n";
alarm(1800);
sleep 60 until !-e "/var/tmp/.sqlhr";
};
`touch "/var/tmp/.sqlhr"`;
alarm(600);
#backup locally
system("/usr/bin/mysqldump -u root -pPASSWORD --databases vpopmail squirrelmail
squirrelmail_calendar > /backups/vpopmail/SQL/$HRFILE.vpopmail_dbase.fox.sql")
== 0 or die &DTBFail("sqldmp");
#send copy of backup to another machine
system("/usr/local/bin/scp -p /backups/sql/fox/$HRFILE.vpopmail_dbase.fox.sql
colt:/opt/fox-sql");
alarm(0);
`rm -f "/var/tmp/.sqlhr"`;
sub DTBFail {
my ($dfail) = @_;
$FDMSG = qq[
Hourly backup of DB files has failed to complete.
Error report says: $dfail
];
%mailnu = ( To => '[EMAIL PROTECTED]',
From => '[EMAIL PROTECTED]',
Subject => 'SQL DB Hourly Backup Failure',
Message => $FDMSG
);
sendmail(%mailnu);
syslog("info", "DB Hourly Backups FAILED - $dfail");
};