dbbu / scripts / dbbu-run.py


import os
import sys
import time
import string
import ConfigParser
from optparse import OptionParser
import dbbu

usage = """usage: %prog <path-to-configuration-file>

Sample Configuration:

# compress backup files (defaults to gzip)
compression: bzip2
# backup destination directory (defaults to current working directory)
dest: /backup/
# chmod backup files, must start with 0 (defaults to 0600)
fmod: 0755

# host 1
# ssh user
user: postgres
# database specifications
postgres: ALL
mysql: ALL

# host n
parser = OptionParser(usage=usage)

def main():
    (options, cfg_path) = parser.parse_args()
    if not cfg_path:
        sys.stderr.write('Configuration file required!\n\n')
    defaults = {'fmod': '0600', 'compression': 'gzip', 'dest': os.getcwd()}
    cfg = ConfigParser.RawConfigParser(defaults)
    shared = {
        'dest': cfg.get('default', 'dest'),
        'compression': cfg.get('default', 'compression'),
        'fmod': string.atoi(cfg.get('default', 'fmod'), 8),
    engines = []
    for host in cfg.sections():
        data = {'host': host}
        if cfg.has_option(host, 'user'):
            data['host'] = '%s@%s' % (cfg.get(host, 'user'), host)
        if cfg.has_option(host, 'postgres'):
            databases = cfg.get(host, 'postgres').strip()
            if databases not in ('ALL', ''):
                data['databases'] = databases.split(',')
        if cfg.has_option(host, 'mysql'):
    for engine in engines:

if __name__ == "__main__":
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.