修复:独立回收中断备份并限制 AI 日志增长
This commit is contained in:
+3
-2
@@ -369,8 +369,7 @@ def create():
|
||||
folder = BACKUP_ROOT / (datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ') + '-' + uuid.uuid4().hex[:8])
|
||||
folder.mkdir(parents=True, exist_ok=False)
|
||||
folder.chmod(0o700)
|
||||
backup_retention.atomic(folder / '.owner.json', {'kind': 'quality-backup', 'root': str(ROOT.resolve()),
|
||||
'id': folder.name, 'createdAt': time.time(), 'ownerPid': os.getpid()})
|
||||
backup_retention.register_candidate(folder, ROOT)
|
||||
sql = folder / 'database.sql.gz'
|
||||
command = [str(project.RUNTIME / 'mysql/bin/mysqldump'), '--defaults-file=' + str(project.RUNTIME / 'mysql-root.cnf'),
|
||||
'--single-transaction', '--hex-blob', '--no-tablespaces', '--set-gtid-purged=OFF', '--skip-add-locks',
|
||||
@@ -378,7 +377,9 @@ def create():
|
||||
process = None
|
||||
try:
|
||||
with tempfile.TemporaryFile() as errors, sql.open('wb') as output:
|
||||
backup_retention.candidate_child(folder, pending=True)
|
||||
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=errors)
|
||||
backup_retention.candidate_child(folder, process.pid)
|
||||
try:
|
||||
with gzip.GzipFile(fileobj=output, mode='wb', compresslevel=1) as compressed:
|
||||
shutil.copyfileobj(process.stdout, compressed)
|
||||
|
||||
Reference in New Issue
Block a user