def backupDatabase(version): log.info(u'Backing up database before upgrade') if not helpers.backup_versioned_file(db.dbFilename(), version): log.error(u'Database backup failed, abort upgrading database') sys.exit(1) else: log.info(u'Proceeding with upgrade')
def backup_database(path, version): """Back up the database.""" log.info('Backing up database before upgrade') if not helpers.backup_versioned_file(path, version): log.error('Database backup failed, abort upgrading database') sys.exit(1) else: log.info('Proceeding with upgrade')
def backup_database(path, version): """Back up the database.""" log.info('Backing up database before upgrade') if not helpers.backup_versioned_file(path, version): log.error('Database backup failed, abort upgrading database') sys.exit(1) else: log.info('Proceeding with upgrade')
def migrate_config(self): """ Calls each successive migration until the config is the same version as SB expects """ if self.config_version > self.expected_config_version: logger.log_error_and_exit( u"""Your config version (%i) has been incremented past what this version of the application supports (%i). If you have used other forks or a newer version of the application, your config file may be unusable due to their modifications.""" % (self.config_version, self.expected_config_version) ) app.CONFIG_VERSION = self.config_version while self.config_version < self.expected_config_version: next_version = self.config_version + 1 if next_version in self.migration_names: migration_name = ': ' + self.migration_names[next_version] else: migration_name = '' log.info(u'Backing up config before upgrade') if not helpers.backup_versioned_file(app.CONFIG_FILE, self.config_version): logger.log_error_and_exit(u'Config backup failed, abort upgrading config') else: log.info(u'Proceeding with upgrade') # do the migration, expect a method named _migrate_v<num> log.info(u'Migrating config up to version {version} {migration_name}', {'version': next_version, 'migration_name': migration_name}) getattr(self, '_migrate_v' + str(next_version))() self.config_version = next_version # save new config after migration app.CONFIG_VERSION = self.config_version log.info(u'Saving config file to disk') app.instance.save_config()