Skip to content

NVR with realtime local object detection for IP cameras

Make a backup DB before doing migrations (#11048)

Nicolas Mowenbaf363fcb03c
diff --git a/frigate/app.py b/frigate/app.py
index 68a5857bfa..94ec8c6c63 100644
--- a/frigate/app.py
+++ b/frigate/app.py
@@ -249,6 +249,14 @@ class FrigateApp:
# Run migrations
del logging.getLogger("peewee_migrate").handlers[:]
router = Router(migrate_db)
+
+ if len(router.diff) > 0:
+ logger.info("Making backup of DB before migrations...")
+ shutil.copyfile(
+ self.config.database.path,
+ self.config.database.path.replace("frigate.db", "backup.db"),
+ )
+
router.run()
# this is a temporary check to clean up user DB from beta