summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2015-07-07 10:58:27 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2015-07-07 10:58:27 +0000
commit474d798c421517a092ddef2861634df6027b1b19 (patch)
tree9385d6049d2cf09615c91d1d18ed3e82e4172c98 /lib
parentf76092c06dd1f3b40a6d32ad3d62ea09bf32d1a0 (diff)
parent69c659ebd3387ec331a30d6bf53d989803f7276f (diff)
downloadgitlab-ce-474d798c421517a092ddef2861634df6027b1b19.tar.gz
Merge branch 'compress-db' into 'master'
Compress database backup Restore handles both cases: uncompressed and compressed backup. As an improvement `IO.popen` can be used. /cc @jacobvosmaer See merge request !873
Diffstat (limited to 'lib')
-rw-r--r--lib/backup/database.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index 9ab6aca276d..f677f8def2b 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -22,9 +22,19 @@ module Backup
end
report_success(success)
abort 'Backup failed' unless success
+
+ $progress.print 'Compressing database ... '
+ success = system('gzip', db_file_name)
+ report_success(success)
+ abort 'Backup failed: compress error' unless success
end
def restore
+ $progress.print 'Decompressing database ... '
+ success = system('gzip', '-d', db_file_name_gz)
+ report_success(success)
+ abort 'Restore failed: decompress error' unless success
+
success = case config["adapter"]
when /^mysql/ then
$progress.print "Restoring MySQL database #{config['database']} ... "
@@ -48,6 +58,10 @@ module Backup
File.join(db_dir, 'database.sql')
end
+ def db_file_name_gz
+ File.join(db_dir, 'database.sql.gz')
+ end
+
def mysql_args
args = {
'host' => '--host',