diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-06-23 16:45:24 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-07-06 18:14:17 +0300 |
commit | 69c659ebd3387ec331a30d6bf53d989803f7276f (patch) | |
tree | e314a7a185f6d035286dcf1cd2dcf23a4dbd73a3 | |
parent | 17446ff0c98e870f0500279983432e5115e060a4 (diff) |
Compress database backup
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | doc/update/mysql_to_postgresql.md | 5 | ||||
-rw-r--r-- | lib/backup/database.rb | 14 |
3 files changed, 20 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index d538bb42992..4bb9714ac7c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -51,6 +51,8 @@ v 7.12.1 - Fix closed merge request scope at milestone page (Dmitriy Zaporozhets) - Revert merge request states renaming - Fix hooks for web based events with external issue references (Daniel Gerhardt) + - Improve performance for issue and merge request pages + - Compress database dumps to reduce backup size v 7.12.0 - Fix Error 500 when one user attempts to access a personal, internal snippet (Stan Hu) diff --git a/doc/update/mysql_to_postgresql.md b/doc/update/mysql_to_postgresql.md index 2c43cf59c1f..8ef3e0d55cc 100644 --- a/doc/update/mysql_to_postgresql.md +++ b/doc/update/mysql_to_postgresql.md @@ -57,12 +57,15 @@ sudo -u git -H git clone https://github.com/gitlabhq/mysql-postgresql-converter. sudo -u git -H mkdir db sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_production.mysql db/database.sql +# Compress database backup +sudo -u git -H gzip db/database.sql + # Replace the MySQL dump in TIMESTAMP_gitlab_backup.tar. # Warning: if you forget to replace TIMESTAMP below, tar will create a new file # 'TIMESTAMP_gitlab_backup.tar' without giving an error. -sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql +sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql.gz # Done! TIMESTAMP_gitlab_backup.tar can now be restored into a Postgres GitLab # installation. Remember to recreate the indexes after the import. 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', |