pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedAutomated database backups and authentication
12+ messages / 9 participants
[nested] [flat]
* Automated database backups and authentication
@ 2002-08-06 18:14 Darren McClelland <darren@zonarsystems.com>
0 siblings, 3 replies; 12+ messages in thread
From: Darren McClelland @ 2002-08-06 18:14 UTC (permalink / raw)
To: pgsql-admin
Hello,
I would like to backup a set of databases from a cron job. It looks like
pg_dumpall will do the trick. The only problem is that there doesn't seem to
be any way to pass the database password to pg_dumpall in a non interactive
manner. I'd like to use some kind of access control on the databases, but it
would need to be able to function non interactively.
Ideally whatever I do would be able to function across a network, so that one
database server could backup to a second - kind of a poor man's replication.
I haven't found any real answers in any of the archives, or docs. Has anyone
here done something like this or have any thoughts?
Thanks,
Darren McClelland
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 18:30 Andrew Sullivan <andrew@libertyrms.info>
parent: Darren McClelland <darren@zonarsystems.com>
2 siblings, 1 reply; 12+ messages in thread
From: Andrew Sullivan @ 2002-08-06 18:30 UTC (permalink / raw)
To: pgsql-admin
On Tue, Aug 06, 2002 at 11:14:47AM -0700, Darren McClelland wrote:
> I haven't found any real answers in any of the archives, or docs. Has anyone
> here done something like this or have any thoughts?
If you control and trust both servers, why not use ident
authentication?
A
--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew@libertyrms.info> M6K 3E3
+1 416 646 3304 x110
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 18:39 Darren McClelland <darren@zonarsystems.com>
parent: Andrew Sullivan <andrew@libertyrms.info>
0 siblings, 3 replies; 12+ messages in thread
From: Darren McClelland @ 2002-08-06 18:39 UTC (permalink / raw)
To: Andrew Sullivan <andrew@libertyrms.info>; pgsql-admin
Thanks, that's an idea. I'd always been thinking of ident as unreliable, but
if I control the authenticating server then it's something usable. At least I
can force an attacker to get root before they can go after the other machine.
That's about the best anyone can hope for.
Darren
On Tuesday 06 August 2002 11:30, Andrew Sullivan wrote:
> On Tue, Aug 06, 2002 at 11:14:47AM -0700, Darren McClelland wrote:
> > I haven't found any real answers in any of the archives, or docs. Has
> > anyone here done something like this or have any thoughts?
>
> If you control and trust both servers, why not use ident
> authentication?
>
> A
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 21:34 Artur Pietruk <arturp@plukwa.pdi.net>
parent: Darren McClelland <darren@zonarsystems.com>
2 siblings, 1 reply; 12+ messages in thread
From: Artur Pietruk @ 2002-08-06 21:34 UTC (permalink / raw)
To: Darren McClelland <darren@zonarsystems.com>; +Cc: pgsql-admin
On Tue, Aug 06, 2002 at 11:39:03AM -0700, Darren McClelland wrote:
> Thanks, that's an idea. I'd always been thinking of ident as unreliable, but
> if I control the authenticating server then it's something usable. At least I
[cut]
Well, if you want to use ident that way, than you have to trust not
only those two servers, but all hosts in their network segments - do not
forget about ARP poisoning.
I think, that in your setup it would be better to do crypt=-auth
and:
- use PGPASSWORD environment variable, just set it before you execute
pg_dumpall. Go and check pgsql-admin list archives - I remember that lately
PG developers stated that PGPASSWORD variable may not be available in the
next PG release - but in that case there will be other way to give password.
Also check online docs: http://www.postgresql.org/idocs/index.php?libpq-envars.html.
OR:
- you can try to pass password to pg_dumpall through tricks like:
"echo mypass | pg_dumpall .... "
Best regards,
--
--- Artur Pietruk, arturp@plukwa.net
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 22:00 Chad R. Larson <clarson@eldocomp.com>
parent: Darren McClelland <darren@zonarsystems.com>
2 siblings, 1 reply; 12+ messages in thread
From: Chad R. Larson @ 2002-08-06 22:00 UTC (permalink / raw)
To: Artur Pietruk <arturp@plukwa.pdi.net>; Darren McClelland <darren@zonarsystems.com>; +Cc: pgsql-admin
At 02:34 PM 8/6/02 , Artur Pietruk wrote:
>I think, that in your setup it would be better to do crypt=-auth and:
>- use PGPASSWORD environment variable, just set it before you execute
>pg_dumpall.
The problem with that is most UNIX systems are able to display the contents
of the environment of a process. Some make it easier than others (on BSD
systems, it is as easy as a switch on "ps") but most can do it.
That was (I believe) the reason that the variable was going away in 7.3,
because it is a security hole.
-crl
--
Chad R. Larson (CRL22) chad@eldocomp.com
Eldorado Computing, Inc. 602-604-3100
5353 North 16th Street, Suite 400
Phoenix, Arizona 85016-3228
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 22:07 John Madden <jmadden@ivytech.edu>
parent: Chad R. Larson <clarson@eldocomp.com>
0 siblings, 1 reply; 12+ messages in thread
From: John Madden @ 2002-08-06 22:07 UTC (permalink / raw)
To: clarson@eldocomp.com; +Cc: arturp@plukwa.pdi.net; darren@zonarsystems.com; pgsql-admin
> The problem with that is most UNIX systems are able to display the
> contents of the environment of a process. Some make it easier than
> others (on BSD systems, it is as easy as a switch on "ps") but most
> can do it.
>
> That was (I believe) the reason that the variable was going away in
> 7.3, because it is a security hole.
Don't those systems only display the environment of the processes that one
owns? That's how it seems on Linux, anyway...
John
--
John Madden
UNIX Systems Engineer
Ivy Tech State College
jmadden@ivytech.edu
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 22:17 Murthy Kambhampaty <Murthy.Kambhampaty@goeci.com>
0 siblings, 0 replies; 12+ messages in thread
From: Murthy Kambhampaty @ 2002-08-06 22:17 UTC (permalink / raw)
To: 'darren@zonarsystems.com' <darren@zonarsystems.com>; pgsql-admin
If you have a few users and many databases, and the user that created the
database will be the one to access it, it might work for you to do a query
on pg_database to get a list of databases and their creators, then do a
pg_dump of each database while passing the password (echo <password>
redirection or expect script) for each database depending on the user. (I
something similar in MySQL, though not the password pasing, and it looks
like it can be done in pSQL also).
Alternatively, it seems you might run pg_dumpall as the superuser and after
dumping all the databases, chown the dump files?
Murthy
"Out of the mouths of babes ..."
>-----Original Message-----
>From: Darren McClelland [mailto:darren@zonarsystems.com]
>Sent: Tuesday, August 06, 2002 14:15
>To: pgsql-admin@postgresql.org
>Subject: [ADMIN] Automated database backups and authentication
>
>
>Hello,
>
>I would like to backup a set of databases from a cron job. It
>looks like
>pg_dumpall will do the trick. The only problem is that there
>doesn't seem to
>be any way to pass the database password to pg_dumpall in a
>non interactive
>manner. I'd like to use some kind of access control on the
>databases, but it
>would need to be able to function non interactively.
>
>Ideally whatever I do would be able to function across a
>network, so that one
>database server could backup to a second - kind of a poor
>man's replication.
>
>I haven't found any real answers in any of the archives, or
>docs. Has anyone
>here done something like this or have any thoughts?
>
>Thanks,
>Darren McClelland
>
>
>---------------------------(end of
>broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-06 23:32 Lee Harr <missive@frontiernet.net>
parent: Darren McClelland <darren@zonarsystems.com>
2 siblings, 0 replies; 12+ messages in thread
From: Lee Harr @ 2002-08-06 23:32 UTC (permalink / raw)
To: pgsql-admin
> I would like to backup a set of databases from a cron job. It looks like
> pg_dumpall will do the trick. The only problem is that there doesn't seem to
> be any way to pass the database password to pg_dumpall in a non interactive
> manner. I'd like to use some kind of access control on the databases, but it
> would need to be able to function non interactively.
>
> Ideally whatever I do would be able to function across a network, so that one
> database server could backup to a second - kind of a poor man's replication.
>
> I haven't found any real answers in any of the archives, or docs. Has anyone
> here done something like this or have any thoughts?
>
I just set this up on my system.
I use expect to take the backups and transfer the files to
another system using scp. I also use some python scripts
to figure out what the names of the backup files should
be (using the date for instance).
Some issues I ran into:
* Since the password will be in the expect script, you need
to be careful with permissions on the script.
* Also, watch your umask for any temporary files you may
create in the process.
* Expect scripts which run fine from the command line will
mysteriously fail from cron (and just hang around not
doing much of anything) I found that using absolute
paths to *everything* solved most of those problems.
* I set the expect log_user variable to 0 so that I do
not get any mail about the process.
* I used: set env(SHELL) /bin/sh
because I was having trouble with figuring out which
shell was going to run, and this seemed easiest.
I am using the same system to run a daily report too.
I had never used cron, and it was tough to get this
working, but now it seems pretty good.
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-07 07:07 Curt Sampson <cjs@cynic.net>
parent: John Madden <jmadden@ivytech.edu>
0 siblings, 0 replies; 12+ messages in thread
From: Curt Sampson @ 2002-08-07 07:07 UTC (permalink / raw)
To: John Madden <jmadden@ivytech.edu>; +Cc: clarson@eldocomp.com, <arturp@plukwa.pdi.net>; darren@zonarsystems.com; pgsql-admin
On Tue, 6 Aug 2002, John Madden wrote:
> Don't those systems only display the environment of the processes that one
> owns? That's how it seems on Linux, anyway...
No, some systems will display the environment of any process.
cjs
--
Curt Sampson <cjs@cynic.net> +81 90 7737 2974 http://www.netbsd.org
Don't you know, in this new Dark Age, we're all light. --XTC
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-07 14:51 Andrew Sullivan <andrew@libertyrms.info>
parent: Artur Pietruk <arturp@plukwa.pdi.net>
0 siblings, 0 replies; 12+ messages in thread
From: Andrew Sullivan @ 2002-08-07 14:51 UTC (permalink / raw)
To: pgsql-admin
On Tue, Aug 06, 2002 at 11:34:58PM +0200, Artur Pietruk wrote:
> On Tue, Aug 06, 2002 at 11:39:03AM -0700, Darren McClelland wrote:
> > Thanks, that's an idea. I'd always been thinking of ident as unreliable, but
> > if I control the authenticating server then it's something usable. At least I
> [cut]
>
> Well, if you want to use ident that way, than you have to trust not
> only those two servers, but all hosts in their network segments - do not
> forget about ARP poisoning.
>
> I think, that in your setup it would be better to do crypt=-auth
> and:
>
> - use PGPASSWORD environment variable, just set it before you execute
If you're worried about people poisoning arp, &c., then you'd have to
be mad to put a password in an environment variable.
If you have this sort of security problem, use Kerberos. It's what
it was designed to solve.
A
--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew@libertyrms.info> M6K 3E3
+1 416 646 3304 x110
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-07 19:03 Darren McClelland <darren@zonarsystems.com>
parent: Darren McClelland <darren@zonarsystems.com>
2 siblings, 0 replies; 12+ messages in thread
From: Darren McClelland @ 2002-08-07 19:03 UTC (permalink / raw)
To: pgsql-admin
Hi,
Thanks to all who responded. Right now I'm partial to using the PGPASSWORD
variable. I was so hung up on looking at the applications I forgot about the
underlying libraries.
I can set the environmental variable in the backup script and make that only
readable by root. It looks like someone would need to be root to look at the
environment of a process they don't own, at least on Linux, which is what I'm
running on. If an attacker has root on the box, it's game over anyway, and
this looks safest from a network based attack.
Thanks again,
Darren McClelland
On Tuesday 06 August 2002 11:14, Darren McClelland wrote:
> Hello,
>
> I would like to backup a set of databases from a cron job. It looks like
> pg_dumpall will do the trick. The only problem is that there doesn't seem
> to be any way to pass the database password to pg_dumpall in a non
> interactive manner. I'd like to use some kind of access control on the
> databases, but it would need to be able to function non interactively.
>
> Ideally whatever I do would be able to function across a network, so that
> one database server could backup to a second - kind of a poor man's
> replication.
>
> I haven't found any real answers in any of the archives, or docs. Has
> anyone here done something like this or have any thoughts?
>
> Thanks,
> Darren McClelland
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Automated database backups and authentication
@ 2002-08-08 22:43 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Darren McClelland <darren@zonarsystems.com>
2 siblings, 0 replies; 12+ messages in thread
From: Bruce Momjian @ 2002-08-08 22:43 UTC (permalink / raw)
To: darren@zonarsystems.com; +Cc: Andrew Sullivan <andrew@libertyrms.info>; pgsql-admin
You can use local/ident if your OS supports it. See pg_hba.conf.
---------------------------------------------------------------------------
Darren McClelland wrote:
> Thanks, that's an idea. I'd always been thinking of ident as unreliable, but
> if I control the authenticating server then it's something usable. At least I
> can force an attacker to get root before they can go after the other machine.
> That's about the best anyone can hope for.
> Darren
>
>
>
> On Tuesday 06 August 2002 11:30, Andrew Sullivan wrote:
> > On Tue, Aug 06, 2002 at 11:14:47AM -0700, Darren McClelland wrote:
> > > I haven't found any real answers in any of the archives, or docs. Has
> > > anyone here done something like this or have any thoughts?
> >
> > If you control and trust both servers, why not use ident
> > authentication?
> >
> > A
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2002-08-08 22:43 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-06 18:14 Automated database backups and authentication Darren McClelland <darren@zonarsystems.com>
2002-08-06 18:30 ` Andrew Sullivan <andrew@libertyrms.info>
2002-08-06 18:39 ` Darren McClelland <darren@zonarsystems.com>
2002-08-06 21:34 ` Artur Pietruk <arturp@plukwa.pdi.net>
2002-08-07 14:51 ` Andrew Sullivan <andrew@libertyrms.info>
2002-08-06 22:00 ` Chad R. Larson <clarson@eldocomp.com>
2002-08-06 22:07 ` John Madden <jmadden@ivytech.edu>
2002-08-07 07:07 ` Curt Sampson <cjs@cynic.net>
2002-08-08 22:43 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-08-06 23:32 ` Lee Harr <missive@frontiernet.net>
2002-08-07 19:03 ` Darren McClelland <darren@zonarsystems.com>
2002-08-06 22:17 Re: Automated database backups and authentication Murthy Kambhampaty <Murthy.Kambhampaty@goeci.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox