PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 17th, 2002, 01:52 AM
niyogi niyogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Austin,TX
Posts: 62 niyogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 55 sec
Reputation Power: 0
automatic backups with postgresql

I'm trying to discover a way to perform automatic backups of postgresql databases.

the issue is that when you execute the pg_dump command from the console, it prompts you for a username and password. because of this *simple* reason, you can't run this as a cronned bash script.

so i'm looking to see how php could be utilized in a standalone script that can "insert" values for the username and password dynamically...

any ideas?

Reply With Quote
  #3  
Old April 18th, 2002, 06:42 PM
niyogi niyogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Austin,TX
Posts: 62 niyogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 55 sec
Reputation Power: 0
unfortunately this is too basic for what I am trying to do...

pg_dump requires that you enter the username and password *after* you issue the command...

-S

Reply With Quote
  #4  
Old April 18th, 2002, 08:51 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
I have never been prompted for a password from pg_dump, as long as I am executing the dump as the 'postgres' user. This should apply to whatever your master postgreSQL user is.

So, if you do as suggested in the other post, and tell cron to su to the correct user, you should have no problem. PostgreSQL inherits its permissions directly from the OS, unlike MySQL.

If this doesn't work, please post exactly what you are trying to do.

On the other hand, yes, it is possible to automate the console response as if entering actual keystrokes. This is probably best done in a Perl script, and then you can just run the Perl script as a cron job.
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #5  
Old April 19th, 2002, 12:11 PM
niyogi niyogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Austin,TX
Posts: 62 niyogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 55 sec
Reputation Power: 0
okay... getting somewhere but now i get the error from the console:

fe_sendauth: No password supplied.


any ideas?

-S

Reply With Quote
  #6  
Old April 19th, 2002, 12:56 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
Hmm... what authentication method have you specified in the pg_hba.conf file?

I believe the line "local all" is a default, which means local users who have already been authenticated by the Unix system are allowed in. If you see instead "local all password", then that might be the explanation for your problem, meaning that passwords are required, even for valid users.

Is this a shared server, where local users might pose a security risk?

Reply With Quote
  #7  
Old April 19th, 2002, 01:07 PM
niyogi niyogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Austin,TX
Posts: 62 niyogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 55 sec
Reputation Power: 0
hi rycamor,

it's not a shared server BUT it is running phpPgAdmin which is effectively a "local" entrance into the server. and you're correct in stating that in the pg_hba.conf file it says "local all password"

is there a way to denote that user postgres can be the only user that doesn't need one?

Reply With Quote
  #8  
Old April 19th, 2002, 04:29 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
Oops, I made a small mistake: the default is "local all trust", not just "local all" (I don't think that would work at all). "local all trust" means the same thing I intended in my post above, which is that validated local Unix users are "trusted".

I don't think there is a way to specify only one user, but you can specify only one database. The format for local users in the conf file is "local DBNAME AUTHTYPE [AUTH_ARGUMENT]".

But, if it is not a shared server, there is no real reason not to just open it up with "local all trust".

Reply With Quote
  #9  
Old May 1st, 2002, 06:47 PM
niyogi niyogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Austin,TX
Posts: 62 niyogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 55 sec
Reputation Power: 0
well, for those of you who are interested in learning how to perform automatic backups, i was successful in my research in finding out how to do this. procedure is briefly outlined below. Email me for more information.

It assumes you are running Red Hat 7.1

1. Chances are that you already have tcl installed on your machine. Download and install the "expect" rpm from the resource below:

http://www.rpmfind.net/linux/rpm2ht...hp?query=expect

rpm -ivh ****.rpm

2. Download the attached dbbackup.zip file and extract the dbbackup.exp file from it. Change it's permissions to execute

chmod +x dbbackup.exp

3. run it in the following form

./dbbackup.exp [username] [password] [databasename]

where you substitute the values of username, password, and databasename.

and voila! everything should work.

Key things to consider

* This doesn't go over the security issues of the above command. I'm working on another php-driven version that dynamically grabs the password of a database if stored *in* a database itself.

* This is meant to be used in conjunction with cron jobs. (That was the whole point anyway.)

Have fun!
Attached Files
File Type: zip dbbackup.zip (275 Bytes, 804 views)

Reply With Quote
  #10  
Old May 4th, 2002, 11:09 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
Cool, I'm going to check it out .

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > automatic backups with postgresql

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap