postgresql - Permission denied when I try to restore postgres backup -
recently used command make backup of postgres databases
pg_dumpall > bkpoldpg.sql after removing old version of postgres downloaded last version 9.4 , have tried restore old data using :
mody@debian:~$ su postgres password: postgres@debian:/home/mody$ postgres@debian:/home/mody$ /usr/lib/postgresql/9.4/bin/psql -d postgres -f documents/bkp01dpg.sql documents/bkp01dpg.sql: permission denied as can see permission denied tried using sudo doesn't work :
postgres@debian:/home/mody$ sudo /usr/lib/postgresql/9.4/bin/psql -d postgres -f documents/bkp01dpg.sql [sudo] password postgres: postgres not in sudoers file. incident reported. any please ?
thanks!
your backup file, or documents folder within, have permissions not permit access postgres user.
you can give postgres user (and other users on system) right read them with:
chmod a+x documents chmod a+r documents/bkp01dpg.sql alternately, copy bkp01dpg.sql location postgres user has access to, give postgres user ownership of it, e.g.
sudo cp documents/bkp01dpg.sql ~postgres/ sudo chown postgres ~postgres/bkp01dpg.sql or run restore under normal user account, connecting postgresql superuser:
psql -u postgres -f documents/bkp01dpg.sql ... though might need modify pg_hba.conf or pg_ident.conf allow user connect postgres if way. (or temporary alter user give normal user superuser rights).
by way, don't need su postgres. in habit of using sudo -u postgres run commands, , sudo -u postgres -i if want interactive command line.