iv class=3D"gmail_quote">On Mon, Mar 22, 2010 at 6:38 AM, blast
=3D"ltr"><
carlosd2002@hotmail=
..com> wrote:
x #ccc solid;padding-left:1ex;">
Hi all,
I need to backup and restore a DB.
In this particular case the data in the database is not important (strange<=
br>
hum...) but only the schema to put new data...
I m thinking use the pg_dump:
pg_dump -c -C -s schema > file.out
A=
lmost....=A0
-s says "only dump the st=
ructure of the database"
If you want to dump a specif=
ic named schema inside the database, you'd use:
-n <schema>
So, w=
hat you end up with is:
=A0pg_dump -c -C -s -n [sc=
hema] [database] > file.out
=A0
l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left=
:1ex;">
With this i have in file.out the schema, correct?
=
Yes
=A0
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
So, to restore the db from scratch, for example to a new system, what shoul=
d
i do?
psql -d [database] -f file.out=A0=
=A0
.8ex;border-left:1px #ccc solid;padding-left:1ex;">
it automatically creates all users, rolls, permissions etc?How?
uote>
To create users, you need to dump them from the so=
urce db first (pg_dump doesn't do users)...=A0
so
pg_dumpall -g > users.sql
psql -=
d [database] -f users.sql=A0
do this BEFORE you do=
the restore of your objects and all your permissions etc... will be set.=
div>
=A0
border-left:1px #ccc solid;padding-left:1ex;">
What is the best way of doing it?
=A0Good luck!=A0
<=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
#ccc solid;padding-left:1ex;">
Many thanks
--
View this message in context:
re-Postgres-DB-tp27984540p27984540.html" target=3D"_blank">http://old.nabbl=
e.com/Backup-Restore-Postgres-DB-tp27984540p27984540.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (
..org">pgsql-admin@postgresql.org)
To make changes to your subscription:
">http://www.postgresql.org/mailpref/pgsql-admin