Skip to content

Commit

Permalink
Backup settings.db before migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
AdwaitSalankar committed Nov 22, 2023
1 parent 98b6462 commit 39b8d3e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/vorta/store/connection.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
import shutil
from datetime import datetime, timedelta

from peewee import Tuple, fn
from playhouse import signals

from vorta import config
from vorta.autostart import open_app_at_startup

from .migrations import run_migrations
Expand Down Expand Up @@ -83,6 +85,7 @@ def init_db(con=None):
if created or current_schema.version == SCHEMA_VERSION:
pass
else:
backup_current_db()
run_migrations(current_schema, con)

# Create missing settings and update labels.
Expand All @@ -98,3 +101,11 @@ def init_db(con=None):
s.tooltip = setting['tooltip']

s.save()


def backup_current_db():
"""
Creates a backup copy of settings.db
"""

shutil.copy(config.SETTINGS_DIR / 'settings.db', config.SETTINGS_DIR / 'settings.db.bak')

0 comments on commit 39b8d3e

Please sign in to comment.