浏览代码

fix: backup before trimming a site database

version-14
Gavin D'souza 3 年前
父节点
当前提交
1c1320c684
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. +7
    -1
      frappe/commands/site.py

+ 7
- 1
frappe/commands/site.py 查看文件

@@ -741,13 +741,19 @@ def build_search_index(context):
@click.command('trim-tables')
@click.option('--dry-run', is_flag=True, default=False, help='Show what would be deleted')
@click.option('--format', default='table', type=click.Choice(['json', 'table']), help='Output format')
@click.option('--no-backup', is_flag=True, default=False, help='Do not backup the site')
@pass_context
def trim_tables(context, dry_run, format):
def trim_tables(context, dry_run, format, no_backup):
from frappe.model.meta import trim_tables
from frappe.utils.backups import scheduled_backup

for site in context.sites:
frappe.init(site=site)
frappe.connect()

if not (no_backup or dry_run):
scheduled_backup(ignore_files=False, force=True)

try:
trimmed_data = trim_tables(dry_run=dry_run)
handle_data(trimmed_data, format=format)


正在加载...
取消
保存