def _backup(backup_dir=None): if not backup_dir: return False source = [ os.path.join(app.DATA_DIR, app.APPLICATION_DB), app.CONFIG_FILE ] if app.BACKUP_CACHE_DB: source += [ os.path.join(app.DATA_DIR, app.FAILED_DB), os.path.join(app.DATA_DIR, app.CACHE_DB), os.path.join(app.DATA_DIR, app.RECOMMENDED_DB) ] target = os.path.join(backup_dir, app.BACKUP_FILENAME.format(timestamp=time.strftime('%Y%m%d%H%M%S'))) if app.BACKUP_CACHE_FILES: for (path, dirs, files) in os.walk(app.CACHE_DIR, topdown=True): for dirname in dirs: if path == app.CACHE_DIR and dirname not in ['images']: dirs.remove(dirname) for filename in files: source.append(os.path.join(path, filename)) return helpers.backup_config_zip(source, target, app.DATA_DIR)
def backup(backupDir=None): """Create backup.""" final_result = '' if backupDir: source = [os.path.join(app.DATA_DIR, app.APPLICATION_DB), app.CONFIG_FILE, os.path.join(app.DATA_DIR, app.FAILED_DB), os.path.join(app.DATA_DIR, app.CACHE_DB), os.path.join(app.DATA_DIR, app.RECOMMENDED_DB)] target = os.path.join(backupDir, 'medusa-{date}.zip'.format(date=time.strftime('%Y%m%d%H%M%S'))) for (path, dirs, files) in os.walk(app.CACHE_DIR, topdown=True): for dirname in dirs: if path == app.CACHE_DIR and dirname not in ['images']: dirs.remove(dirname) for filename in files: source.append(os.path.join(path, filename)) if helpers.backup_config_zip(source, target, app.DATA_DIR): final_result += 'Successful backup to {location}'.format(location=target) else: final_result += 'Backup FAILED' else: final_result += 'You need to choose a folder to save your backup to!' final_result += '<br>\n' return final_result
def backup(backupDir=None): final_result = '' if backupDir: source = [os.path.join(app.DATA_DIR, app.APPLICATION_DB), app.CONFIG_FILE, os.path.join(app.DATA_DIR, app.FAILED_DB), os.path.join(app.DATA_DIR, app.CACHE_DB)] target = os.path.join(backupDir, 'medusa-{date}.zip'.format(date=time.strftime('%Y%m%d%H%M%S'))) for (path, dirs, files) in os.walk(app.CACHE_DIR, topdown=True): for dirname in dirs: if path == app.CACHE_DIR and dirname not in ['images']: dirs.remove(dirname) for filename in files: source.append(os.path.join(path, filename)) if helpers.backup_config_zip(source, target, app.DATA_DIR): final_result += 'Successful backup to {location}'.format(location=target) else: final_result += 'Backup FAILED' else: final_result += 'You need to choose a folder to save your backup to!' final_result += '<br>\n' return final_result
def _backup(backupDir=None): if not backupDir: return False source = [ os.path.join(app.DATA_DIR, app.APPLICATION_DB), app.CONFIG_FILE, os.path.join(app.DATA_DIR, app.FAILED_DB), os.path.join(app.DATA_DIR, app.CACHE_DB) ] target = os.path.join(backupDir, app.BACKUP_FILENAME.format(timestamp=time.strftime('%Y%m%d%H%M%S'))) for (path, dirs, files) in os.walk(app.CACHE_DIR, topdown=True): for dirname in dirs: if path == app.CACHE_DIR and dirname not in ['images']: dirs.remove(dirname) for filename in files: source.append(os.path.join(path, filename)) return helpers.backup_config_zip(source, target, app.DATA_DIR)
def _backup_to_zip(self, backup_dir): """Create a backup and save to zip.""" final_result = '' if backup_dir: source = [ os.path.join(app.DATA_DIR, app.APPLICATION_DB), app.CONFIG_FILE ] if app.BACKUP_CACHE_DB: source += [ os.path.join(app.DATA_DIR, app.FAILED_DB), os.path.join(app.DATA_DIR, app.CACHE_DB), os.path.join(app.DATA_DIR, app.RECOMMENDED_DB) ] target = os.path.join( backup_dir, 'medusa-{date}.zip'.format(date=time.strftime('%Y%m%d%H%M%S'))) log.info(u'Starting backup to location: {location} ', {'location': target}) if app.BACKUP_CACHE_FILES: for (path, dirs, files) in os.walk(app.CACHE_DIR, topdown=True): for dirname in dirs: if path == app.CACHE_DIR and dirname not in ['images']: dirs.remove(dirname) for filename in files: source.append(os.path.join(path, filename)) if helpers.backup_config_zip(source, target, app.DATA_DIR): final_result += 'Successful backup to {location}'.format( location=target) else: final_result += 'Backup FAILED' else: final_result += 'You need to choose a folder to save your backup to!' final_result += '<br>\n' log.info(u'Finished backup to location: {location} ', {'location': target}) return self._ok(data={'result': final_result})