summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-21 17:18:38 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-21 17:18:38 +0200
commit845947b925cdea25abedccecb862f2a1ee9b961c (patch)
treee190bac962e89a7e765073b99c9e3cab301d38d2
parentd26b4fa5388121b441545b3dc2b61651784c6802 (diff)
downloadgitlab-ci-845947b925cdea25abedccecb862f2a1ee9b961c.tar.gz
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
-rw-r--r--lib/backup/database.rb7
-rwxr-xr-xlib/support/mysql-postgresql-converter/splice_drop_indexes4
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 }'