Skip to content

Commit

Permalink
add fab command to pull in production database
Browse files Browse the repository at this point in the history
  • Loading branch information
copelco committed Apr 21, 2015
1 parent 4d808bf commit 19542af
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,18 @@ def deploy():
target = "-G 'environment:{0}'".format(env.environment)
salt('saltutil.sync_all', target)
highstate(target)

@task
def reset_local_db(confirm_first=True):
""" Reset local database from remote host """
require('environment', provided_by=('production',))
if confirm_first:
question = 'Are you sure you want to reset your local ' \
'database with the %(environment)s database?' % env
if not confirm(question, default=False):
abort('Local database reset aborted.')
with settings(warn_only=True):
local('dropdb school_inspector')
local('createdb school_inspector')
remote_db = 'school_inspector_production'
local('ssh -C %s sudo -u postgres pg_dump -Ox %s | psql school_inspector' % (env.master, remote_db, ))

0 comments on commit 19542af

Please sign in to comment.