Deploy generic rattail-backup
script for backup apps
This commit is contained in:
parent
5df0e0d16f
commit
f860b2185b
|
@ -37,6 +37,15 @@ from rattail_fabric import make_deploy, mkdir, python, UNSPECIFIED
|
|||
deploy_generic = make_deploy(__file__)
|
||||
|
||||
|
||||
def deploy_rattail_backup_script(**context):
|
||||
"""
|
||||
Deploy the generic `rattail-backup` script
|
||||
"""
|
||||
context.setdefault('envname', 'backup')
|
||||
deploy_generic('backup/rattail-backup.mako', '/usr/local/bin/rattail-backup',
|
||||
mode='0700', context=context)
|
||||
|
||||
|
||||
def deploy_backup_everything(**context):
|
||||
"""
|
||||
Deploy the generic `backup-everything` script
|
||||
|
@ -49,6 +58,7 @@ def deploy_backup_everything(**context):
|
|||
|
||||
def deploy_backup_app(deploy, envname, mkvirtualenv=True, user='rattail',
|
||||
python_exe='/usr/bin/python3',
|
||||
rattail_backup_script=None,
|
||||
config=None, everything=None, crontab=None, runat=UNSPECIFIED):
|
||||
"""
|
||||
Make an app which can run backups for the server.
|
||||
|
@ -93,6 +103,14 @@ def deploy_backup_app(deploy, envname, mkvirtualenv=True, user='rattail',
|
|||
sudo('bin/rattail -c app/rattail.conf make-config -T quiet -O app/', user=user)
|
||||
sudo('bin/rattail -c app/rattail.conf make-config -T silent -O app/', user=user)
|
||||
|
||||
# rattail-backup script
|
||||
script_context = {'envname': envname}
|
||||
if rattail_backup_script:
|
||||
deploy(rattail_backup_script, '/usr/local/bin/rattail-backup', mode='0700',
|
||||
context=script_context)
|
||||
else:
|
||||
deploy_rattail_backup_script(**script_context)
|
||||
|
||||
# backup-everything script
|
||||
everything_context = {
|
||||
'envname': envname,
|
||||
|
|
13
rattail_fabric/deploy/backup/rattail-backup.mako
Executable file
13
rattail_fabric/deploy/backup/rattail-backup.mako
Executable 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 $*
|
Loading…
Reference in a new issue