MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / backup_db_file

Function backup_db_file

web/pgadmin/__init__.py:367–385  ·  view source on GitHub ↗

Create a backup of the current database file and create new database file with default settings.

()

Source from the content-addressed store, hash-verified

365 from pgadmin.setup import db_upgrade
366
367 def backup_db_file():
368 """
369 Create a backup of the current database file
370 and create new database file with default settings.
371 """
372 backup_file_name = "{0}.{1}".format(
373 SQLITE_PATH, datetime.now().strftime('%Y%m%d%H%M%S'))
374 os.rename(SQLITE_PATH, backup_file_name)
375 app.logger.error('Exception in database migration.')
376 app.logger.info('Creating new database file.')
377 try:
378 db_upgrade(app)
379 os.environ[
380 'CORRUPTED_DB_BACKUP_FILE'] = backup_file_name
381 app.logger.info('Database migration completed.')
382 except Exception:
383 app.logger.error('Database migration failed')
384 app.logger.error(traceback.format_exc())
385 raise RuntimeError('Migration failed')
386
387 def upgrade_db():
388 """

Callers 2

upgrade_dbFunction · 0.85
run_migration_for_sqliteFunction · 0.85

Calls 4

db_upgradeFunction · 0.90
errorMethod · 0.80
infoMethod · 0.80
renameMethod · 0.65

Tested by

no test coverage detected