Commit 6c73ce68 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

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
parents d26b4fa5 845947b9
......@@ -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
......
......@@ -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 }'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment