changed so sync now goes TO the destination branch, also changed variable name fro clarity
modified: modules/database.py
This commit is contained in:
parent
441f8b4be6
commit
7d6c179f6a
1 changed files with 23 additions and 12 deletions
|
|
@ -2,7 +2,7 @@ from fabric.api import env, task
|
|||
# # from jinja2 import Environment
|
||||
import os
|
||||
from utils import upload_template as utils_upload_template
|
||||
from utils import loggify, print_console
|
||||
from utils import loggify, print_console, booleanize
|
||||
# from utils import prompt_continue
|
||||
from getpass import getpass
|
||||
import fabric.operations as fabric_ops
|
||||
|
|
@ -229,14 +229,14 @@ def commandline(dbuser='default'):
|
|||
|
||||
@task
|
||||
def backup(dbuser='default', backup_file=None, branch=None,
|
||||
filedump_only=False):
|
||||
datadump_only=False):
|
||||
"""
|
||||
creates a dump of the database for backup and storage
|
||||
|
||||
dbuser - set to "default" but can also be set to "admin"
|
||||
backup_file - specify name of the backup_file otherwise use default value
|
||||
branch - what branch to apply this function to (default env.current)
|
||||
filedump_only - only output the results of pg_dump
|
||||
datadump_only - only output the results of pg_dump
|
||||
|
||||
the admin user is what it says, I have both of these in case I need to
|
||||
switch between the master user for the entire postgres install or the owner
|
||||
|
|
@ -276,7 +276,11 @@ def backup(dbuser='default', backup_file=None, branch=None,
|
|||
configuration.paths.server.backups.database,
|
||||
backup_file)
|
||||
|
||||
if not filedump_only:
|
||||
datadump_only = booleanize(datadump_only)
|
||||
|
||||
print "dumpfilename: %s" % dumpfilename
|
||||
|
||||
if not datadump_only:
|
||||
|
||||
# NOTE
|
||||
# the "tee" command takes input and pipes it to a file and to standard
|
||||
|
|
@ -289,6 +293,7 @@ def backup(dbuser='default', backup_file=None, branch=None,
|
|||
user=user,
|
||||
dumpfilename=dumpfilename
|
||||
)
|
||||
|
||||
else:
|
||||
# this only spits output, it does not save a file
|
||||
|
||||
|
|
@ -300,7 +305,9 @@ def backup(dbuser='default', backup_file=None, branch=None,
|
|||
user=user,
|
||||
)
|
||||
|
||||
output = run_database_command(cmd_pg_dump, user, True)
|
||||
print "cmd_pg_dump: %s" % cmd_pg_dump
|
||||
|
||||
output = run_database_command(cmd_pg_dump, user)
|
||||
|
||||
return output
|
||||
|
||||
|
|
@ -369,18 +376,17 @@ def restore(dbuser='default', backup_file=None, reinitialize=True):
|
|||
|
||||
|
||||
@task
|
||||
def sync(src):
|
||||
def sync(dst):
|
||||
"""
|
||||
sync from source databases to calling branch
|
||||
src - the source database
|
||||
sync from current branch database to destination branch
|
||||
dst - the destination database
|
||||
"""
|
||||
configuration = env.config
|
||||
|
||||
branch_src = src
|
||||
import initialize
|
||||
|
||||
configuration_src = initialize.environment(branch_src)
|
||||
configuration_dst = configuration
|
||||
branch_dst = dst
|
||||
configuration_src = configuration
|
||||
configuration_dst = initialize.environment(branch_dst)
|
||||
|
||||
print "branch_src: %s" % configuration_src.project.branch
|
||||
print "branch_dst: %s" % configuration_dst.project.branch
|
||||
|
|
@ -390,8 +396,13 @@ def sync(src):
|
|||
backup_name_dst = "backup_sync_dst.sql"
|
||||
backup_name_src = "backup_sync_src.sql"
|
||||
|
||||
print "output_src = backup("
|
||||
print "\tbackup_file=%s," % backup_name_src
|
||||
print "\tbranch=%s)" % configuration_src.project.branch
|
||||
|
||||
# dump the source database to our {destination}/backups/database
|
||||
print "backup up src: %s" % configuration_src.project.branch
|
||||
|
||||
output_src = backup(
|
||||
backup_file=backup_name_src,
|
||||
branch=configuration_src.project.branch)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue