Bacula-users

Re: [Bacula-users] howto to recover postgres catalog after delete from file

2011-05-20 12:59:56
Subject: Re: [Bacula-users] howto to recover postgres catalog after delete from file
From: Martin Simmons <martin AT lispworks DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Fri, 20 May 2011 17:56:37 +0100
>>>>> On Fri, 20 May 2011 13:57:45 +0200 (CEST), Thomas Stegbauer said:

> ----- Ursprüngliche Mail -----
> Von: "Martin Simmons" <martin AT lispworks DOT com> 
> An: bacula-users AT lists.sourceforge DOT net 
> Gesendet: Freitag, 20. Mai 2011 12:06:59 
> Betreff: Re: [Bacula-users] howto to recover postgres catalog after delete 
> from file 
> 
>>>>> On Thu, 19 May 2011 18:54:58 +0200 (CEST), Thomas Stegbauer said: 
> > 
> > but after the backup job i get: 
> > 9-Mai 05:23 pa-server-dir JobId 2268: Fatal error: sql_create.c:894 Fill 
> > File table Query failed: INSERT INTO File (FileIndex, JobId, PathId, 
> > FilenameId, LStat, MD5)SELECT batch.FileIndex, batch.JobId, Path.PathId, 
> > Filename.FilenameId,batch.LStat, batch.MD5 FROM batch JOIN Path ON 
> > (batch.Path =3D Path.Path) JOIN Filename ON (batch.Name =3D Filename.Name): 
> > ERR=3DERROR: null value in column "fileid" violates not-null constraint 
> > 
> > how to i get the catalog up and running? 
> 
> It looks like the schema for the file table was damaged. 
> 
> What is the output of 
> 
> \d 
> \d file 
> 
> in psql? 
> 
> __Martin 
> ------------------------------------------------------------------------------
>  

You didn't run the first command (\d).


> \d file 
> Table "public.file" 
> Column | Type | Modifiers 
> ------------+---------+-------------------- 
> fileid | bigint | not null 
> fileindex | integer | not null default 0 
> jobid | integer | not null 
> pathid | integer | not null 
> filenameid | integer | not null 
> markid | integer | not null default 0 
> lstat | text | not null 
> md5 | text | not null 

Thats is definitely wrong -- fileid should have a default.

You could try to fix it, but it might be simpler to dump the data to a text
file using pg_dump -a, then drop the whole bacula database, recreate it using
bacula's scripts and then pg_restore the data.

__Martin

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users