Обсуждение: Backing up users?

Поиск
Список
Период
Сортировка

Backing up users?

От
Mauri Sahlberg
Дата:
Hi,

This might be a stupid question as it is not covered in the 7.4.7 and
probably obvious to all others. Where do the system catalogs live? How
to back them up? Should I back them up?

The admin manual states that to restore a pg_dumped database you should
have those users created that will have permission related to objects
created by pg_restore but gives no clear instructions how to back the
users up and how to restore them before restoring the database.

According to the manual, pg_dumps are relative to template0 so all
modifications relative to it will be backed up as well. This gives me a
reason to believe that users could live in template0  but do they?

What if I just wish to move a single database with it's users to a new
machine? It would be a disaster to overwrite whole existing system
catalog on the target machine.

Is it sufficient to select rows from pg_shadow and pg_group that are
related to the database in question and insert them in the new
environment? (The rows to use could probably be deducted from other
catalog tables and views by queries...)

Regards,
Mauri Sahlberg

Re: Backing up users?

От
Bruno Wolff III
Дата:
On Sat, Apr 30, 2005 at 11:16:59 +0300,
  Mauri Sahlberg <Mauri.Sahlberg@claymountain.com> wrote:
> Hi,
>
> This might be a stupid question as it is not covered in the 7.4.7 and
> probably obvious to all others. Where do the system catalogs live? How
> to back them up? Should I back them up?
>
> The admin manual states that to restore a pg_dumped database you should
> have those users created that will have permission related to objects
> created by pg_restore but gives no clear instructions how to back the
> users up and how to restore them before restoring the database.

You want to use pg_dumpall.

Re: Backing up users?

От
Tom Lane
Дата:
Mauri Sahlberg <Mauri.Sahlberg@claymountain.com> writes:
> What if I just wish to move a single database with it's users to a new
> machine? It would be a disaster to overwrite whole existing system
> catalog on the target machine.

Users (and groups) are global across each Postgres installation.
So what you'd need to do is something like this:

pg_dump the desired database, and do "pg_dumpall -g" to get a script
recreating all your users and groups.  Edit out the non-pertinent
part of that script.  Run the users/groups script and then the pg_dump
script on the target machine.

            regards, tom lane