Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions workerfacing_api/core/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import os
import pickle
import subprocess
import sqlite3
import tempfile
import threading
import time
Expand Down Expand Up @@ -603,8 +603,12 @@ def backup(self) -> bool:
with tempfile.TemporaryDirectory() as temp_dir:
tmp_backup_path = os.path.join(temp_dir, "backup.db")
tmp_gzip_path = os.path.join(temp_dir, "backup.db.gz")
backup_cmd = ["sqlite3", self.db_path, f".backup {tmp_backup_path}"]
subprocess.run(backup_cmd, text=True, check=True)

# Use Python's sqlite3 backup API instead of command-line tool
with sqlite3.connect(self.db_path) as source_conn:
with sqlite3.connect(tmp_backup_path) as backup_conn:
source_conn.backup(backup_conn)

with open(tmp_backup_path, "rb") as f_in:
with gzip.open(tmp_gzip_path, "wb") as f_out:
f_out.writelines(f_in)
Expand Down