summaryrefslogtreecommitdiff
path: root/lib/backup/database.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-06-23 15:45:24 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-06 17:14:17 +0200
commit69c659ebd3387ec331a30d6bf53d989803f7276f (patch)
treee314a7a185f6d035286dcf1cd2dcf23a4dbd73a3 /lib/backup/database.rb
parent17446ff0c98e870f0500279983432e5115e060a4 (diff)
downloadgitlab-ce-69c659ebd3387ec331a30d6bf53d989803f7276f.tar.gz
Compress database backup
Diffstat (limited to 'lib/backup/database.rb')
-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',