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 24, 2023
1 parent 39b8d3e commit 45b5c83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/vorta/store/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def init_db(con=None):
if created or current_schema.version == SCHEMA_VERSION:
pass
else:
backup_current_db()
backup_current_db(current_schema.version)
run_migrations(current_schema, con)

# Create missing settings and update labels.
Expand All @@ -103,9 +103,10 @@ def init_db(con=None):
s.save()


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

shutil.copy(config.SETTINGS_DIR / 'settings.db', config.SETTINGS_DIR / 'settings.db.bak')
backup_file_name = f'settings_v{schema_version}.db.bak'
shutil.copy(config.SETTINGS_DIR / 'settings.db', config.SETTINGS_DIR / backup_file_name)

0 comments on commit 45b5c83

Please sign in to comment.