Files
orion/scripts/backup_database.py
2025-09-21 13:00:10 +02:00

36 lines
873 B
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# scripts/backup_database.py
"""Simple backup for early development."""
import os
import shutil
from datetime import datetime
from pathlib import Path
def backup_current_db():
"""Quick backup of current database."""
db_path = "ecommerce.db"
if not os.path.exists(db_path):
print(" No existing database found - nothing to backup")
return
# Create backup directory
backup_dir = Path("backups")
backup_dir.mkdir(exist_ok=True)
# Create timestamped backup
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
backup_path = backup_dir / f"ecommerce_pre_reset_{timestamp}.db"
try:
shutil.copy2(db_path, backup_path)
print(f"✅ Database backed up to: {backup_path}")
except Exception as e:
print(f"⚠️ Backup failed: {e}")
if __name__ == "__main__":
backup_current_db()