Skip to content

Instantly share code, notes, and snippets.

@iggy
Last active August 29, 2015 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iggy/366611900342234aa184 to your computer and use it in GitHub Desktop.
Save iggy/366611900342234aa184 to your computer and use it in GitHub Desktop.
# Tell each db server to run the pgsql command to coalesce the database
coalesce_db:
salt.function:
- name: postgres.psql_query
- tgt: 'tags:db'
- tgt_type: grain
- arg:
- "select pg_start_backup('foo');"
# we want our salt master to run the cloud snapshot script
# TODO at some point move this to use salt.cloud.* functionality
db_snapshot:
salt.function:
- name: cmd.run
# FIXME switch to complex match, but it wasn't working
- tgt: 'tags:master'
- tgt_type: grain
- arg:
- /path/to/cloud.py snapshot --tags db -- {{ salt['grains.get']('ocsenv') }}
# now that the master has snapshotted the volumes, unfreeze the DB servers
unfreeze_db:
salt.function:
- name: postgres.psql_query
- tgt: 'tags:db'
- tgt_type: grain
- arg:
- "select pg_stop_backup();"
croniter:
pip.installed
db-backup-job:
schedule.present:
- function: state.orchestrate
- args:
- backups.db.orchestrate
- cron: '0 3 * * *'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment