|
From: <di...@us...> - 2008-11-19 19:06:02
|
Revision: 624
http://safekeep.svn.sourceforge.net/safekeep/?rev=624&view=rev
Author: dimi
Date: 2008-11-19 19:05:57 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
Allow passing the pgpasswd to PostgreSQL as well.
Modified Paths:
--------------
safekeep/trunk/doc/safekeep.backup.txt
safekeep/trunk/safekeep
safekeep/trunk/safekeep.spec.in
Modified: safekeep/trunk/doc/safekeep.backup.txt
===================================================================
--- safekeep/trunk/doc/safekeep.backup.txt 2008-11-19 18:40:03 UTC (rev 623)
+++ safekeep/trunk/doc/safekeep.backup.txt 2008-11-19 19:05:57 UTC (rev 624)
@@ -179,8 +179,10 @@
based on the system user.
/backup/setup/dump/@dbpasswd::
- Password of the database user to use while doing the dump.
- This is currently supported only for MySQL databases.
+ Password of the database user to use while doing the dump.
+ NB: this makes the DB password available in a plain text file.
+ Make sure you use appropriate read permissions on the backup
+ configuration file to prevent unauthorized access to the password.
Optional, it has no default value.
/backup/setup/dump/@options::
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2008-11-19 18:40:03 UTC (rev 623)
+++ safekeep/trunk/safekeep 2008-11-19 19:05:57 UTC (rev 624)
@@ -403,6 +403,7 @@
for dump in cfg['dumps']:
type = dump['type']
opts = dump['opts']
+ passwdfile = None
if type in ('postgres', 'postgresql', 'pgsql'):
if dump['db']:
args = ['pg_dump']
@@ -414,6 +415,12 @@
args.extend(opts)
if dump['db']:
args.append(dump['db'])
+ if dump['dbpasswd']:
+ (fd, passwdfile) = tempfile.mkstemp()
+ f = file(fd)
+ f.write(dump['dbpasswd'])
+ f.close()
+
elif type in ('mysql'):
args = ['mysqldump']
if dump['dbuser']:
@@ -425,15 +432,26 @@
args.extend(opts)
if dump['db']:
args.append(dump['db'])
+
else:
warn('Invalid database type: ' + type)
continue
+
if dump['user']:
cmd = ' '.join([commands.mkarg(arg) for arg in args])
args = [ 'su', '-c', cmd, '-', dump['user'] ]
cmd = ' '.join([commands.mkarg(arg) for arg in args])
cmd = '%s > %s' % (cmd, commands.mkarg(dump['file']))
- ec = spawn(cmd)
+
+
+ if passwdfile:
+ environ['PGPASSFILE'] = passwdfile
+ try:
+ ec = spawn(cmd)
+ finally:
+ if passwdfile:
+ del os.environ['PGPASSFILE']
+ os.remove(passwdfile)
if ec:
warn('Can not dump the database: ' + dump['db'])
Modified: safekeep/trunk/safekeep.spec.in
===================================================================
--- safekeep/trunk/safekeep.spec.in 2008-11-19 18:40:03 UTC (rev 623)
+++ safekeep/trunk/safekeep.spec.in 2008-11-19 19:05:57 UTC (rev 624)
@@ -116,6 +116,7 @@
%doc sample.backup
%changelog
+ - Allow passing the pgpasswd to PostgreSQL as well
- Add pass-through options for the DB dump command
- Implement bandwidth limiting, based on trickle
- By default, run safekeep with nice +10 on the server side
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|