Make a backup DB before doing migrations (#11048)

This commit is contained in:
Nicolas Mowen
2024-04-20 07:55:51 -06:00
committed by GitHub
parent 57800d3843
commit baf363fcb0

View File

@@ -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