How to backup/dump Postgre SQL

Hello,

I need to backup or dump the database to a .bak file, it´s Request Tracker 4.0.7.
Frits i tried this:
root@rt:~# pg_dump rtdb > rtdb-backup
pg_dump: [archove (db)] connection against database “rtdb” failed: FATAL: role “root” does not exist

Then i tried:
root@rt:~# su postgres
postgres@rt:/root$ pg_dump rtdb > rtdb-backup
bash: rtdb-backup: Access denied

What do i have to do to create a backup of the database?

Martin Petersson
IT-Konsult

+46 (0)522 980 28, martin@uanet.semailto:martin@uanet.se, www.uanet.sehttp://www.uanet.se/
Gustaf Mattssons Väg 2, 451 50 Uddevalla, Orgnr: 556702-4095

[cid:A93F8E95-F3FC-464A-AF04-402618F91147@uanet.local] http://www.uanet.se/
http://www.uanet.se/

Then i tried:
root@rt:~# su postgres
postgres@rt:/root$ pg_dump rtdb > rtdb-backup
bash: rtdb-backup: Access denied

What do i have to do to create a backup of the database?

Not be in roots home directory when you run pg_dump.

Later,
Darin

Hello,

I need to backup or dump the database to a .bak file, it´s Request Tracker 4.0.7.
Frits i tried this:
root@rt:~# pg_dump rtdb > rtdb-backup
pg_dump: [archove (db)] connection against database “rtdb” failed: FATAL: role “root” does not exist

Then i tried:
root@rt:~# su postgres
postgres@rt:/root$ pg_dump rtdb > rtdb-backup
bash: rtdb-backup: Access denied

What do i have to do to create a backup of the database?

Use ‘su - postgres’ instead to become postgres instead of just get the permissions of postgres. If that doesn’t work because it doesn’t have a shell try sudo but ultimately you need to be in a place you can write to while having the permissions of postgres or specify the location in the redirect.

eg:

su postgres

$ pg_dump rtdb -> /tmp/rtdb-backup

Landon Stewart
Lead Analyst - Abuse and Security Management
INTERNAP ®
:e-mail: lstewart@internap.commailto:lstewart@internap.com
:earth_africa: www.internap.comhttp://www.internap.com

eg:

su postgres

$ pg_dump rtdb -> /tmp/rtdb-backup

OOPS

su postgres

$ pg_dump rtdb > /tmp/rtdb-backup

Landon Stewart
Lead Analyst - Abuse and Security Management
INTERNAP ®
:e-mail: lstewart@internap.commailto:lstewart@internap.com
:earth_africa: www.internap.comhttp://www.internap.com

Hello,

I need to backup or dump the database to a .bak file, it´s Request Tracker 4.0.7.
Frits i tried this:
root@rt:~# pg_dump rtdb > rtdb-backup
pg_dump: [archove (db)] connection against database “rtdb” failed: FATAL: role “root” does not exist

this is postgres permission error

Then i tried:
root@rt:~# su postgres
postgres@rt:/root$ pg_dump rtdb > rtdb-backup
bash: rtdb-backup: Access denied

this is file local host file system permission error.

What do i have to do to create a backup of the database?

you can use the -U and -p flags to specify username and password to pg_dump so you don’t need to worry about the su / sudo stuff

cd /tmp
pg_dump -U postgres rtdb > rtdb-backup

If your db required a password then you can specify the -p flag such as…

pg_dump -U postgres -p rtdb > rtdb-backup

and it will prompt you for it.

-Patrick

Patrick Muldoon
Network/Software Engineer
INOC (http://www.inoc.net)

RAM DISK is not an installation procedure!

Thank you all very much.

This one did the trick. su - postgres

A little dash in between :slight_smile:

Skickat fr?n min ? iPhone

5 aug. 2016 kl. 21:13 skrev Landon Stewart <lstewart@internap.commailto:lstewart@internap.com>:

eg:

su postgres

$ pg_dump rtdb -> /tmp/rtdb-backup

OOPS

su postgres

$ pg_dump rtdb > /tmp/rtdb-backup

Landon Stewart
Lead Analyst - Abuse and Security Management
INTERNAP ®
? lstewart@internap.commailto:lstewart@internap.com
? www.internap.comhttp://www.internap.com