ajout paramètres tmp_dir = '/tmp' et encoding = 'UTF8' pour le driver backup pgsql

This commit is contained in:
htouvet 2018-02-06 15:21:55 +01:00
parent 1190eb4d9d
commit c29ad67075

View File

@ -33,9 +33,11 @@ class backup_pgsql(backup_generic):
"""Backup a postgresql database as gzipped sql file through ssh"""
type = 'pgsql+ssh'
required_params = backup_generic.required_params + ['private_key']
optional_params = backup_generic.optional_params + ['db_name']
optional_params = backup_generic.optional_params + ['db_name','tmp_dir','encoding']
db_name=''
db_name = ''
tmp_dir = '/tmp'
encoding = 'UTF8'
def do_backup(self,stats):
self.dest_dir = os.path.join(self.backup_dir,self.backup_start_date)
@ -85,7 +87,11 @@ class backup_pgsql(backup_generic):
t = datetime.datetime.now()
backup_start_date = t.strftime('%Y%m%d-%Hh%Mm%S')
# dump db
cmd = " su - postgres -c 'pg_dump "+ self.db_name + ' > /tmp/' + self.db_name + '-' + backup_start_date + ".sql '"
cmd = " su - postgres -c 'pg_dump -E %(encoding)s %(db_name)s > %(tmp_dir)s/%(db_name)s-%(backup_start_date)s.sql'" % {
'encoding':self.encoding,
'db_name':self.db_name,
'tmp_dir':self.tmp_dir,
'backup_start_date':backup_start_date}
self.logger.debug('[%s] %s ',self.backup_name,cmd)
if not self.dry_run:
(error_code,output) = ssh_exec(cmd,ssh=self.ssh)