Package Camelot :: Package camelot :: Package core :: Module backup :: Class BackupMechanism |
[frames] | no frames]

# Class BackupMechanism

source code

Create a backup of the current database to an sqlite database stored in filename.

The backupmechanism always considers the schema of the backed up database as the master, and never that of the backup. This means that when a backup is made, the backup file is first removed, and then filled with the tables from the the database to backup. When a restore is done, the schema of the database is not touched, but the tables are emptied and the data from the backup is copied into the existing schema.

Instance Methods
__init__(self, filename) Backup and restore to a local file using it as an sqlite database | source code
backup_table_filter(self, from_table) Method used to filter which tables should be backed up, overwrite this method for taking into account specific schema issues. | source code
restore_table_filter(self, from_table) Method used to filter which tables should be restored, overwrite this method for taking into account specific schema issues. restore_table_filter is different from backup_table_filter, since we might want to store data in the backup that should not be restored, like schema version information. | source code
prepare_schema_for_restore(self, from_engine, to_engine) This method will be called before the actual restore starts. It allows bringing the schema at the same revision as the backed up data. | source code
update_schema_after_restore(self, from_engine, to_engine) This method will be called after the restore has been done. It allows bringing the schema at the revision the application expects. | source code
backup(self) Generator function that yields tuples : (numer_of_steps_completed, total_number_of_steps, description_of_current_step) while performing a backup. | source code
restore(self) Generator function that yields tuples : (numer_of_steps_completed, total_number_of_steps, description_of_current_step) while performing a restore. | source code
delete_table_data(self, to_table) This method might be subclassed to turn off/on foreign key checks | source code
copy_table_data(self, from_table, to_table) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, filename) (Constructor) | source code
Backup and restore to a local file using it as an sqlite database Overrides: object.__init__

### backup_table_filter(self, from_table) | source code
Method used to filter which tables should be backed up, overwrite this method for taking into account specific schema issues. Returns: True when the table should be backed up

### restore_table_filter(self, from_table) | source code
Method used to filter which tables should be restored, overwrite this method for taking into account specific schema issues. restore_table_filter is different from backup_table_filter, since we might want to store data in the backup that should not be restored, like schema version information. Returns: True when the table should be restored