0

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 .

  • `pg_dumpall` is not a SQL command, you need to run it outside of `psql`. Why are you working as `root` to begin with? You need to provide a proper username then `pg_dumpall -U postgres ...` –  Sep 13 '19 at 10:35
  • Ok. But it's a remote server. So, i am logging into the root of remote server. Yes, the user which i provided above unify is a superuser – akhilesh kedarisetty Sep 13 '19 at 10:40
  • Then use that for `pg_dumpall` as well. –  Sep 13 '19 at 10:41

1 Answers1

0

"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.

jjanes
  • 37,812
  • 5
  • 27
  • 34