Skip to content

Instantly share code, notes, and snippets.

@alksl
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save alksl/87b98489d6cb98e64b4d to your computer and use it in GitHub Desktop.

Select an option

Save alksl/87b98489d6cb98e64b4d to your computer and use it in GitHub Desktop.
#!/bin/zsh
if [ "$#" -ne 2 ]; then
echo "Usage: $0 [infile] [outfile]"
exit 1
fi
export PGPASSWORD=password
pushd gitlab-5-0
RAILS_ENV=production bundle exec rake db:drop db:create db:migrate
popd
psql -h 10.0.1.11 -U postgres -d gitlabhq_production -f $1
pushd gitlab-7-0;
RAILS_ENV=production bundle exec rake db:migrate
popd
pg_dump -h 10.0.1.11 \
-U postgres \
--no-privileges \
--no-acl \
--no-owner \
--clean \
gitlabhq_production > $2
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 [user] [database]"
exit 1
fi
echo "UPDATE pg_cast SET castcontext='a' WHERE casttarget = 'boolean'::regtype;"
echo "SET standard_conforming_strings=off;"
echo "SET escape_string_warning=off;"
echo "SET CONSTRAINTS ALL DEFERRED;"
mysqldump --no-create-info \
--skip-triggers \
--compatible=postgresql \
--default-character-set=utf8 \
--skip-add-locks \
--single-transaction \
--skip-comments \
--ignore-table=${2}.schema_migrations \
-u $1 -p $2
echo "UPDATE pg_cast SET castcontext='e' WHERE casttarget = 'boolean'::regtype;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment