2.7. Backing Up and Protecting Data

GnuCash creates several types of files to help ensure that your data is not lost. You may see the following file extensions: xac, log, LCK, LNK. Each time you save your data file, a backup copy will also be saved with the extension xac. This backup file is a complete copy of your previous data file, and the filename format refers to the data file, year, month, day and time of the backup. For example, the filename gcashdata.20010404185747.xac indicates this is a backup copy of the file gcashdata saved in the year 2001, April 4, at 6:57:47 p.m.

Each time you open a file in GnuCash, a .log is created and saved with the same name format as the .xac backup files. As you make changes to the open data file, the log file saves only those changes. Log files are not a full backup of your data file - they simply record changes you have made to the data file in the current GnuCash session.

You may occasionally see .LNK and .LCK files appear. These do not store any data, but they are created to prevent more than one user from opening the same file at the same time. These files are automatically created when you open the file, to lock it so no one else can access it. When you close your GnuCash session or open another file, GnuCash unlocks the first data file by deleting the LCK and LNK files.

If GnuCash crashes while you have a data file open, the LCK and LNK files are not deleted. The next time you try to open GnuCash, you will get a warning message that the file is locked. The warning message appears because the LNK and LCK files are still in your directory. It is safe to choose Yes to open the file, but you should delete the .LNK and .LCK files (using a terminal window or your file manager.) Once those files are deleted, you will not get the warning message again unless GnuCash crashes.

So which files should you keep around? Keep your main data file, of course - data files do not have an automatic file extension. It's a good idea to keep some of the more recent .xac files, but you can safely delete the .log files since they are not complete copies of your data. You should also delete any .LCK and .LNK files that you see after closing GnuCash. If you decide to manually back up your data file to another disk, you only need to back up the main data file - not the .xac files.