MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _restore_database

Function _restore_database

apps/backups/services.py:315–335  ·  view source on GitHub ↗

Restore database from backup.

(temp_path: Path, metadata: dict)

Source from the content-addressed store, hash-verified

313
314
315def _restore_database(temp_path: Path, metadata: dict) -> None:
316 """Restore database from backup."""
317 db_type = metadata.get("database_type", "postgresql")
318 db_file = metadata.get("database_file", "database.dump")
319 dump_file = temp_path / db_file
320
321 if not dump_file.exists():
322 raise ValueError(f"Invalid backup: missing {db_file}")
323
324 current_db_type = "postgresql" if _is_postgresql() else "sqlite"
325
326 if db_type != current_db_type:
327 raise ValueError(
328 f"Database type mismatch: backup is {db_type}, "
329 f"but current database is {current_db_type}"
330 )
331
332 if db_type == "postgresql":
333 _restore_postgresql(dump_file)
334 else:
335 _restore_sqlite(dump_file)
336
337
338def list_backups() -> list[dict]:

Callers 1

restore_backupFunction · 0.85

Calls 5

_is_postgresqlFunction · 0.85
_restore_postgresqlFunction · 0.85
_restore_sqliteFunction · 0.85
getMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected