backup — Camelot documentation

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- core »

# backup

class `camelot.core.backup.` `BackupMechanism`(filename, storage=None)

  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`()

    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)

    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)

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

  classmethod `get_default_storage`()

    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`()

    Returns: | a string with the prefix for the default name of the backup file

    By default this method returns an empty string, 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)

    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`()

    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)

    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)

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

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- core »

Comments
blog comments powered by Disqus