GnuCash backup files

Geert Janssens janssens-geert at telenet.be
Fri Oct 12 11:44:04 EDT 2012


On 10/09/2012 03:26 PM, Cristian Marchi wrote:
> I've a question about the auto deletion of backup files by GnuCash 
> older than X days as set in preferences: does it remove the files 
> based on timestamp or by parsing the date in the filename? I've an 
> Italian user reporting the deletion of a GnuCash file that he 
> currently used with a filename set as a backup file. I was wondering 
> if GnuCash could have deleted the file because its filename was 
> composed with a date older than X days.
> I'll try with an example: let's say my financial data are managed in a 
> file named "data.20120101.gnucash" saved last time on 2012.01.01. 
> Let's say I have preferences set to remove backup files after 5 days. 
> Now if I open the previous file on 2012.01.08 (more than five days 
> later) could my file be deleted by GnuCash? And what if the same file 
> with the same name was saved last time less than five days before the 
> reopening?
>
Cristian,

Your example is not completely clear to me, I'm afraid. Can you give 
more details about the filenames (you talk of opening a backup file, but 
don't specify what it is called exactly for example).

In general (from reading the code) I see there are a lot of rigorous 
checks in the old file cleanup code. Let's take datafile 
example.20120101.gnucash and backup file 
example.20120101.20120930225014.gnucash as example files below:
1. any file that doesn't end in .LCK, .xac, .gnucash or .log are never 
touched.
2. any file that does not begin with the name of the opened file is 
skipped. So if you open the datafile, any file that doesn't start with 
example.20120101.gnucash will be skipped. Our backup file begins with 
this string, so it's still a candiate for deletion. If on the other hand 
you open the backup file, the normal data file will be skipped, because 
it doesn't start with example.20120101.20120930225014.gnucash
3. The opened file itself is skipped, so if you open the data file, that 
file itself will not be deleted. If you open the backup file, the backup 
file won't be deleted.
4. Files ending in .LCK get a special treatment (only the active 
lockfile is kept), but that's not relevant to your questions.
5. At this point possible candidates to be deleted should
    a. start with the open file's name
    b. end in .log, .gnucash, or .xac
The next check now is whether there are a dot and 14 digits right before 
the extension. That's the timestamp gnucash adds to the backup and log 
files. If this patterns isn't found, the file is skipped. So if you open 
the data file, the backup file above still matches all criteria up until 
now.
6. Finally the code checks if the file is older than the retention time 
defined in the preferences. This doesn't use the timestamp in the 
filename, but the file's actual modified time.

This is so both in current 2.4 branch as in trunk.
> While talking about this feature, when GnuCash checks for the deletion 
> of backup files? every time you start it?
>
Yes.

Regards,

Geert


More information about the gnucash-devel mailing list