Thread: Replacing data

Replacing data

From
chelsea boot
Date:
Hi
 
I want to replace all the data in a database with an earlier backup I took.  I have a plain sql-script dump (backup.sql) and am using the following command to replace the current data:
 
psql -U postgres dbname < backup.sql
 
However, the command seems to append the data to the database so that I have the old data and any new data added since the backup was taken.  How can I replace all the data so that my database only contains data from the backup?  Maybe I'm using the wrong backup and restore method?
 
Thanks

Send instant messages to your online friends http://uk.messenger.yahoo.com

Re: Replacing data

From
Frank Bax
Date:
At 07:22 AM 6/15/06, chelsea boot wrote:
>I want to replace all the data in a database with an earlier backup I
>took.  I have a plain sql-script dump (backup.sql) and am using the
>following command to replace the current data:
>
>psql -U postgres dbname < backup.sql
>
>However, the command seems to append the data to the database so that I
>have the old data and any new data added since the backup was taken.  How
>can I replace all the data so that my database only contains data from the
>backup?  Maybe I'm using the wrong backup and restore method?


Looks like you missed -c option of pg_dump during backup.  For this time
only, you could use '-c -s' options to drop/create all objects, then
restore the way you did above.



Re: Replacing data

From
Aarni Ruuhimäki
Date:
On Thursday 15 June 2006 14:22, chelsea boot wrote:
> Hi
>
>   I want to replace all the data in a database with an earlier backup I
> took.  I have a plain sql-script dump (backup.sql) and am using the
> following command to replace the current data:
>
>   psql -U postgres dbname < backup.sql
>
>   However, the command seems to append the data to the database so that I
> have the old data and any new data added since the backup was taken.  How
> can I replace all the data so that my database only contains data from the
> backup?  Maybe I'm using the wrong backup and restore method?
>
>   Thanks
>
>  Send instant messages to your online friends http://uk.messenger.yahoo.com

Hi,

pg_dump -c

creates a dump file which when run will first remove everything and then
create everything and then load the data.

See pg_dump --help for more options.

BR,

Aarni


--------------
This is a bugfree broadcast to you
from **Kmail**
on **Fedora Core** linux system
--------------