MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / backup_database

Function backup_database

scripts/clear_database.py:47–56  ·  view source on GitHub ↗

Create a timestamped database backup before mutating any records.

(db_path: Path = DB_PATH, backup_dir: Path = BACKUP_DIR)

Source from the content-addressed store, hash-verified

45
46
47def backup_database(db_path: Path = DB_PATH, backup_dir: Path = BACKUP_DIR) -> Path:
48 """Create a timestamped database backup before mutating any records."""
49 if not db_path.exists():
50 raise FileNotFoundError(f"Database file not found: {db_path}")
51
52 backup_dir.mkdir(parents=True, exist_ok=True)
53 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
54 backup_path = backup_dir / f"paperflow_{timestamp}.db"
55 shutil.copy2(db_path, backup_path)
56 return backup_path
57
58
59def get_connection(db_path: Path = DB_PATH) -> sqlite3.Connection:

Callers 3

full_resetFunction · 0.85
benchmark_resetFunction · 0.85
mainFunction · 0.85

Calls 1

nowMethod · 0.80

Tested by

no test coverage detected