Skip to content

Commit

Permalink
Make a backup DB before doing migrations (#11048)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 authored Apr 20, 2024
1 parent 57800d3 commit baf363f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frigate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ def cleanup_timeline_db(db: SqliteExtDatabase) -> None:
# 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
Expand Down

0 comments on commit baf363f

Please sign in to comment.