def main(config_file): config = config_from_file(config_file) for section, settings in config.items(): # create directory for backup if 'backup_dir' in settings and \ not os.path.exists(settings['backup_dir']): os.makedirs(settings['backup_dir']) # create empty git repo if not os.path.exists(os.path.join(settings['backup_dir'], '.git')): git_init(settings['backup_dir']) if settings['type'] in ['mysql', 'pgsql']: # backup database print run_command(construct_dump_command(settings, settings['type'])) else: # backup files files_dir = os.path.join(settings['files_dir'], '.') backup_dir = settings['backup_dir'] print run_command('cp -a {0} {1}'.format(files_dir, backup_dir)) # add changes in repo git_add_all(settings['backup_dir']) # get status message for commit status_message = git_status(settings['backup_dir']) print status_message # commit changes git_commit(settings['backup_dir'], status_message) # add remote for pushing git_remote_add(settings['backup_dir'], settings['git_remote']) # push changes git_push(settings['backup_dir']) # done print 'Done! {0} backuped!'.format(section)
def push(self, args=None): config = self.get_project_config() for m in config["modules"]: git_push(self.root_dir, m, args)
def push(root, config, args=None): for m in config["modules"]: git_push(root_dir, m)