Deploy generic rattail-backup script for backup apps

This commit is contained in:
Lance Edgar 2019-09-11 18:36:43 -05:00
parent 9adc5a5b79
commit 63b86593f1
2 changed files with 32 additions and 0 deletions

View file

@ -35,6 +35,15 @@ from rattail_fabric2 import python, exists, make_deploy, mkdir, UNSPECIFIED
deploy_generic = make_deploy(__file__)
def deploy_rattail_backup_script(c, **context):
"""
Deploy the generic `rattail-backup` script
"""
context.setdefault('envname', 'backup')
deploy_generic(c, 'backup/rattail-backup.mako', '/usr/local/bin/rattail-backup',
mode='0700', context=context, use_sudo=True)
def deploy_backup_everything(c, **context):
"""
Deploy the generic `backup-everything` script
@ -47,6 +56,7 @@ def deploy_backup_everything(c, **context):
def deploy_backup_app(c, deploy, envname, mkvirtualenv=True, user='rattail',
config=None, context={}, everything=None,
rattail_backup_script=None,
crontab=None, runat=UNSPECIFIED):
"""
Make an app which can run backups for the server.
@ -86,6 +96,15 @@ def deploy_backup_app(c, deploy, envname, mkvirtualenv=True, user='rattail',
c.sudo("bash -l -c 'workon {} && cdvirtualenv && bin/rattail -c app/rattail.conf make-config -T quiet -O app/'".format(envname), user=user)
c.sudo("bash -l -c 'workon {} && cdvirtualenv && bin/rattail -c app/rattail.conf make-config -T silent -O app/'".format(envname), user=user)
# rattail-backup script
script_context = dict(context)
script_context['envname'] = envname
if rattail_backup_script:
deploy(c, rattail_backup_script, '/usr/local/bin/rattail-backup', mode='0700', use_sudo=True,
context=script_context)
else:
deploy_rattail_backup_script(c, **script_context)
# backup-everything script
everything_context = dict(context)
everything_context['envname'] = envname

View file

@ -0,0 +1,13 @@
#!/bin/sh -e
if [ "$1" = "-v" -o "$1" = "--verbose" ]; then
VERBOSE='--verbose'
CONFIG='/srv/envs/${envname}/app/rattail.conf'
else
VERBOSE=
CONFIG='/srv/envs/${envname}/app/silent.conf'
fi
cd /srv/envs/${envname}
bin/rattail -c $CONFIG $VERBOSE backup $*