diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-09-21 15:22:12 +0000 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-09-21 15:22:12 +0000 |
commit | 6c73ce6880c81cb0173815f0090c2db2ba36c135 (patch) | |
tree | e190bac962e89a7e765073b99c9e3cab301d38d2 | |
parent | d26b4fa5388121b441545b3dc2b61651784c6802 (diff) | |
parent | 845947b925cdea25abedccecb862f2a1ee9b961c (diff) | |
download | gitlab-ci-6c73ce6880c81cb0173815f0090c2db2ba36c135.tar.gz |
Merge branch 'ci-final-migration' into 'master'
Final backup fixes
- Dump postgres with --no-owner and use conversion only
- Execute postgres converter only when using mysql
- Use gzip instead of zcat as more portable way to cat gziped file
@jacobvosmaer For you to merge.
See merge request !252
-rw-r--r-- | lib/backup/database.rb | 7 | ||||
-rwxr-xr-x | lib/support/mysql-postgresql-converter/splice_drop_indexes | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb index 93403d6..4abdfa1 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -33,7 +33,7 @@ module Backup when "postgresql" then $progress.print "Dumping PostgreSQL database #{config['database']} ... " pg_env - spawn('pg_dump', '--clean', *TABLES.map { |t| "--table=#{t}" }, config['database'], out: compress_wr) + spawn('pg_dump', '--no-owner', '--clean', *TABLES.map { |t| "--table=#{t}" }, config['database'], out: compress_wr) end compress_wr.close @@ -41,7 +41,10 @@ module Backup report_success(success) abort 'Backup failed' unless success - convert_to_postgresql if mysql_to_postgresql + + if mysql_to_postgresql && config["adapter"] =~ /^mysql/ + convert_to_postgresql + end end def convert_to_postgresql diff --git a/lib/support/mysql-postgresql-converter/splice_drop_indexes b/lib/support/mysql-postgresql-converter/splice_drop_indexes index 6621ab0..dc13f81 100755 --- a/lib/support/mysql-postgresql-converter/splice_drop_indexes +++ b/lib/support/mysql-postgresql-converter/splice_drop_indexes @@ -15,7 +15,7 @@ if [ -z "$db_gz" ] || [ -z "$drop_indexes_sql" ] ; then fi # Capture all text up to the first occurence of 'SET CONSTRAINTS' -preamble=$(zcat "$db_gz" | sed '/SET CONSTRAINTS/q') +preamble=$(gzip -cd "$db_gz" | sed '/SET CONSTRAINTS/q') if [ -z "$preamble" ] ; then fail "Could not read preamble" fi @@ -34,4 +34,4 @@ EOF # Print the rest of database.sql.gz. I don't understand this awk script but it # prints all lines after the first match of 'SET CONSTRAINTS'. -zcat "$db_gz" | awk 'f; /SET CONSTRAINTS/ { f = 1 }' +gzip -cd "$db_gz" | awk 'f; /SET CONSTRAINTS/ { f = 1 }' |