Skip to content

Backup files

OmegaT creates several backup files when saving a project. Here is an explanation of under the hood.

Behavior when save translation saved

Actual work is done in ProjectTMX#save

  1. check save action is necessary
  2. OmegaT creates a new file, "project_save.tmx.new"
  3. write data into "project_save.tmx.new"
  4. check the existence of backup file "project_save.tmx.bak"
  5. if existed, remove old backup file.
  6. rename "project_save.tmx" to "project_save.tmx.bak"
  7. rename "project_save.tmx.new" to "project_save.tmx" (*1)

This is a sequence when a project is no-team one.

Team project backup of translations

A backup file with a name that have timestamp is created by team sync feature.

After saving "project_save.tmx" in previous steps, as same as no-team project, OmegaT try to sync with remote team repository. It is happened after showing status message "TEAM_SYNCHRONIZE".

When remote file has been modified BY OTHER TRANSLATORS, OmegaT find a difference from a last status, OmegaT decided to make backup, then OmegaT move local file (*1) to "project_save.tmx.YYYYMMDDhhmm.bak" and store merged tmx to "project_save.tmx".

Now you will find three files.

  1. "project_save.tmx.bak" -- "project_save.tmx" file just before save.
  2. "project_save.tmx.YYYYMMDDhhmm.bak" -- "project_save.tmx" file just after save translator worked.
  3. "project_save.tmx" -- which has both translations by the translator and other translators.

If another translator does not work on the project during the translator working, there is NOT a "project_save.tmx.YYYYMMDDhhmm.bak" is not made because there is no difference between (*1) and the last project file.

backup file of omegat.project

When opening a project, OmegaT checks a project properties by reading local omegat.project file. A process is defined in ProjectUICommands#projectOpenImpl. If failed to load project properties, OmegaT try to load backup file. There can be several backup files, that can be maximum 10 files, with timestamped file name. OmegaT manage backup timestamp using FileUtil.getRecentBackup utility function.

After OmegaT open a project, teamwork or not, start a creation of backup file. If the project is non-team and there is no modification during project validation, OmegaT skip a backup file craetion. When the project is teamwork, and there is an update in project properties, OmegaT creates a backup file.

The backup file creation process is guarded with Core.executeExclusively. OmegaT checks again project properties to load. If failed to load, OmegaT aborts the process to keep current files. Then OmegaT checks a status that a process to open the project made a difference from previous project properties. A backup file name is determined by utility function FileUtil.backupFile. OmegaT clean an oldest backup file by calling FileUtil.removeOldBackups utility function when create a new backup file.