backup

class camelot.core.backup.BackupMechanism(filename, storage=None)[source]

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

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.

backup()[source]

Generator function that yields tuples : (numer_of_steps_completed, total_number_of_steps, description_of_current_step) while performing a backup.

backup_table_filter(from_table)[source]

Method used to filter which tables should be backed up, overwrite this method for taking into account specific schema issues.

From_table :the table that is considered for backup
Returns:True when the table should be backed up
delete_table_data(to_table)[source]

This method might be subclassed to turn off/on foreign key checks

get_backup_column_type(from_type)[source]

This function converts column types from the source database to to column types in the backup database. This is needed when backing up from for example MySQL to SQLite, since column types differ between both databases. Overwrite this method to support different columns and/or database types.

Parameters:from_type – the column type in the database that is backed up
Returns:the corresponding column type in the back up database
classmethod get_default_storage()[source]
Returns:a camelot.core.files.storage.Storage object

Returns the storage to be used to store default backups.

By default, this will return a Storage that puts the backup files in the DataLocation as specified by the QDesktopServices

classmethod get_filename_prefix()[source]
Returns:a string with the prefix for the default name of the backup file

By default this method returns ‘backup’, overwrite this method to return a custom string, like the name of the company or such.

This method will be called inside the model thread.

prepare_schema_for_restore(from_engine, to_engine)[source]

This method will be called before the actual restore starts. It allows bringing the schema at the same revision as the backed up data.

restore()[source]

Generator function that yields tuples : (numer_of_steps_completed, total_number_of_steps, description_of_current_step) while performing a restore.

restore_table_filter(from_table)[source]

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.

From_table :the table that is considered for backup
Returns:True when the table should be restored
update_schema_after_restore(from_engine, to_engine)[source]

This method will be called after the restore has been done. It allows bringing the schema at the revision the application expects.

Previous topic

auto_reload

Next topic

conf

This Page