Use pg_dump -Z to compress the output on the fly
Less temp files overhead, less space used in tmp_dir, and less code. -Z is supported since PostgreSQL 7.1.
This commit is contained in:
parent
8ab66245ff
commit
5a1e984a0b
@ -93,17 +93,9 @@ class backup_pgsql(backup_generic):
|
|||||||
'dest_dir':self.dest_dir,
|
'dest_dir':self.dest_dir,
|
||||||
'backup_start_date':backup_start_date}
|
'backup_start_date':backup_start_date}
|
||||||
# dump db
|
# dump db
|
||||||
cmd = "su - postgres -c 'pg_dump -E %(encoding)s %(db_name)s > %(tmp_dir)s/%(db_name)s-%(backup_start_date)s.sql'" % params
|
filepath = '%(tmp_dir)s/%(db_name)s-%(backup_start_date)s.sql.gz' % params
|
||||||
self.logger.debug('[%s] %s ',self.backup_name,cmd)
|
cmd = "su - postgres -c 'pg_dump -E %(encoding)s -Z9 %(db_name)s'" % params
|
||||||
if not self.dry_run:
|
cmd += ' > ' + filepath
|
||||||
(error_code,output) = ssh_exec(cmd,ssh=self.ssh)
|
|
||||||
self.logger.debug("[%s] Output of %s :\n%s",self.backup_name,cmd,output)
|
|
||||||
if error_code:
|
|
||||||
raise Exception('Aborting, Not null exit code (%i) for "%s"' % (error_code,cmd))
|
|
||||||
|
|
||||||
# zip the file
|
|
||||||
cmd = 'gzip %(tmp_dir)s/%(db_name)s-%(backup_start_date)s.sql' % params
|
|
||||||
|
|
||||||
self.logger.debug('[%s] %s ',self.backup_name,cmd)
|
self.logger.debug('[%s] %s ',self.backup_name,cmd)
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
(error_code,output) = ssh_exec(cmd,ssh=self.ssh)
|
(error_code,output) = ssh_exec(cmd,ssh=self.ssh)
|
||||||
@ -112,7 +104,6 @@ class backup_pgsql(backup_generic):
|
|||||||
raise Exception('Aborting, Not null exit code (%i) for "%s"' % (error_code,cmd))
|
raise Exception('Aborting, Not null exit code (%i) for "%s"' % (error_code,cmd))
|
||||||
|
|
||||||
# get the file
|
# get the file
|
||||||
filepath = '%(tmp_dir)s/%(db_name)s-%(backup_start_date)s.sql.gz' % params
|
|
||||||
localpath = '%(dest_dir)s/%(db_name)s-%(backup_start_date)s.sql.gz' % params
|
localpath = '%(dest_dir)s/%(db_name)s-%(backup_start_date)s.sql.gz' % params
|
||||||
self.logger.debug('[%s] get the file using sftp from "%s" to "%s" ',self.backup_name,filepath,localpath)
|
self.logger.debug('[%s] get the file using sftp from "%s" to "%s" ',self.backup_name,filepath,localpath)
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
|
Loading…
Reference in New Issue
Block a user