Server Backup in postgres

181 Views Asked by At

I have to take backup of a remote server and restore it. So, whats the best way to take backup of whole server?

After logging into the root server i have tried:-

[root@server-14 ~]# pg_dumpall > clus.bak
pg_dumpall: could not connect to database "template1": FATAL:  role "root" does not exist

So, i logged into the psql prompt with the superuser -U unify

[root@server-14 ~]# psql -U unify
psql (9.3.25)
Type "help" for help.

unify=# pg_dumpall -U unify37 -f ~/tmp/clus.sql
unify-# 

But even this is throwing a error. The above two ways didn't get me a backup of server and have no idea what might be the problem .

1

There are 1 best solutions below

0
jjanes On

"pg_dumpall" is run from the OS command prompt, not from inside "psql". It takes many of the same argument as "psql". IF you use "-U unify" for psql, then use it for pg_dumpall as well.

pg_dumpall -U unify > clus.bak

Maybe you want to use unify37 instead, that is something only you can know.