LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-19-2014, 07:44 AM   #1
sir-lancealot
Member
 
Registered: Aug 2007
Posts: 346

Rep: Reputation: 31
Full postgres backup - restore keeps asking for password


ok, I am a MySQL guy (really 1st time touching postgres) but doing some work to help someone and there moving to Amazon RDS. The server has around 110 databases, so I did a pg_dumpall and have my file (2.2G) and doing an import.

So here is the problem. It stars by prompting for the postgres PW, I enter and then it seems to create all the tables, then prompts again. I enter it and it looks like it restores all the data for that database, then prompts again, restores, and on and on. I would like to just issue the restore and walk away for the restore.

I created a .pgpass file but the problem I see with that doc is shows this as the "what to put in that file";
hostname : port : database : username : password

So do I need to copy/paste that 100+ times changing the database name for each or is there another way?

I am issuing the following command;
psql -f full.sql --host=rdsURL --port=5432 --username=postgres --password
(and I tried without the password prompt)

Thanks for all read/replies
 
Old 04-19-2014, 09:16 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I know where you are. I am a mysql person as well, and administrating postgres drives me nuts. I am sure it has its merits but I haven't discovered them yet.

You have to change some defaults in the /etc/postgresql/pg_hba file. I donīt exactly recall what they were, but mine look likes this now:

Code:
# Database administrative login by UNIX sockets
local   all         postgres                                        ident sameuser
#
# All other connections by UNIX sockets
local   all         all                                             ident sameuser
#
# All IPv4 connections from localhost
host    all         all         127.0.0.1         255.255.255.255   ident sameuser
#
And my .pgpass file looks like this:
Code:
server.domain.com:5432:*:admin:mypass
I think the secret is in the '*' for the database name.

I am not sure how large a security hole I created with altering the pg_hba. Be sure to plug it back once you are done. Or try to understand what you are doing

Oh, and be extremely careful restoring databases. If you forget to specify which database has to be restored, you are restoring into the template0 database or so. Very disturbing. When you make a database dump (there are 3 or 4 different methods to do so) the database database name is not included by default either.

jlinkels

Last edited by jlinkels; 04-19-2014 at 09:24 AM.
 
1 members found this post helpful.
Old 04-19-2014, 10:34 PM   #3
sir-lancealot
Member
 
Registered: Aug 2007
Posts: 346

Original Poster
Rep: Reputation: 31
Thanks, I guess I was thinking out loud, a database is a database, a few monitor differences, but yes, I am looking for the benefit!

Well, I can't touch the hba conf as this is being move to amazon's RDS and not a server, BUT, looking at your second change (* for the database), I made that change, issued the same restore command and next thing I know, it's flying by never asking!

So, that really did solve it. Now as for the temlate0, etc. I have no clue, but there trying to get a postgres DBA part time, so I have plenty of other tasks ahead of me, this was get we get the data over, so this now shows I can (pgadmin login shows all my data).

I will move on to other tasks, and as the staging area get's set, I will let him confirm things are correct, but what a time saver.

Thanks much .. have a great night!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Full rsync restore from backup causing boot errors pobrika Linux - Server 4 01-16-2014 10:46 AM
[SOLVED] Hard drive partitioning, backup and restore full disk images Tem2 Linux - Newbie 36 01-17-2012 08:33 AM
backup the RHEL5 server with Cpanel and create full system restore disk zaki Linux - Newbie 1 08-31-2009 11:59 AM
Postgres database backup - trust relationship and password noir911 Linux - Server 1 10-02-2008 09:45 AM
Backup and restore accounts and password jorasmi Slackware 1 02-17-2005 09:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration