def setup(): backupator_root = get_backupator_root() backup_dir = get_backup_dir() if backup_dir is not None: run("mkdir -p %s" % (backup_dir,)) else: abort(red("The backup_dir is not set in %s hostdef" % (hostdef.get("hostname")))) if backupator_root is not None: run("mkdir -p %s" % (backupator_root, )) with cd(backupator_root): run("rm -rf src env") run("virtualenv --no-site-package env") run("git clone [email protected]:Quelquechose/backupator.git src") with prefix("source env/bin/activate"): run("pip install -r src/requirements.txt") else: abort(red("The backupator_root is not set in %s hostdef" % (hostdef.get("hostname"))))
def dump(dbname, user, passwd, host="localhost"): filename = "%s_%s.sql" % (dbname, datetime.now().strftime("%Y%m%d_%H%M%S")) destination = "%s/mysql" % (get_backup_dir(),) lrun("mkdir -p %s" % (destination,)) lrun("mysqldump -h %s -u %s -p%s %s > %s/%s" % (host, user, passwd, dbname, destination, filename))