Difference between revisions of "Backup"
(moved .log files entry from the faq) |
(filename entry from faq) |
||
Line 8: | Line 8: | ||
Other SQL-type backends, utilizing database servers, are best backed-up using the related server's backup mechanism, as for any other database. | Other SQL-type backends, utilizing database servers, are best backed-up using the related server's backup mechanism, as for any other database. | ||
+ | |||
+ | == FAQ == | ||
Below are related FAQ entries. | Below are related FAQ entries. | ||
Line 30: | Line 32: | ||
:Note that .log files are to be used only if you are using an XML backend for the book. With SQL storage, it is not recommended to replay the .log files. The data is always saved to the data store and the possibility of data loss is minimal in that case. | :Note that .log files are to be used only if you are using an XML backend for the book. With SQL storage, it is not recommended to replay the .log files. The data is always saved to the data store and the possibility of data loss is minimal in that case. | ||
:This topic is covered more broadly in [https://www.gnucash.org/docs/v3/C/gnucash-guide/basics-backup1.html Backing Up and Recovering Data] section of the User Guide. | :This topic is covered more broadly in [https://www.gnucash.org/docs/v3/C/gnucash-guide/basics-backup1.html Backing Up and Recovering Data] section of the User Guide. | ||
+ | |||
+ | ===='''Q:''' Why is my file name getting longer and longer?==== | ||
+ | |||
+ | :'''A:''' GnuCash creates a backup file by taking the current data file and adding the date/time to the end (YYYYMMDDHHMMSS.gnucash). Older versions up to 2.3.x still used the form YYYYMMDDHHMMSS.xac - from GnuCash's ancestor XAccountant. So if you're using a file named "Foo.gnucash", then you'll get backups of the form: | ||
+ | |||
+ | : Foo.gnucash.20100719100214.gnucash | ||
+ | |||
+ | :Now assume that instead of opening "Foo.gnucash" you open one of these backup files, you make changes to it and then save the file. | ||
+ | :For starters, this means you've just over-written the original backup file which is always a bad idea. Backups should never be changed. | ||
+ | :Secondly since you saved changes, GnuCash will create a backup file based the file you just changed using the same naming system: it adds a date/time extension. Since the file you saved already had such an extension, you end up with a backup file named: | ||
+ | |||
+ | : Foo.gnucash.20100719100214.gnucash.20100719112352.gnucash | ||
+ | |||
+ | :Repeating this process will add to the file name until it exceeds the operating system limits. | ||
+ | |||
+ | :The fix: | ||
+ | |||
+ | :1) Don't open a backup file | ||
+ | :1a) If you DO open a backup file, '''never''' simply save it out again, instead use Save As to give it a new name. | ||
+ | :2) Make sure you're always using your base data file | ||
+ | :3) If your base data file for some reason is bad, and you need to recover from a previous backup file, copy the backup file over your bad base file, for example: | ||
+ | |||
+ | : cp Foo.gnucash.20100719100214.gnucash.20100719112352.gnucash Foo.gnucash | ||
+ | |||
+ | :and then File -> Open the new file, Foo.gnucash. |
Revision as of 07:31, 11 May 2018
How one creates a backup of GnuCash data depends mostly on the type of backend used to store the book information.
XML backends, the default GnuCash data store, include an automatic mechanism which will create a dated copy of your book every time the changes are saved. It will also create .log files which contain changes made in between the saves.
SQLite backend uses SQLite database file as the data store for the book. This means it is fairly simple to back up this file by manually creating a copy or utilizing one of many file backup tools available. Note that, even though there is no automatic backup file generated when using SQLite backend, GnuCash will still generate the .log files with changes. This allows recovering the transactions in certain cases of disaster by replaying the .log files on top of the last backup file. Of course, it is expected that you have a backup file available so, in this case, it is extremely useful to have your own backup scheme applied to the GnuCash book file(s). More info in the related bug.
Other SQL-type backends, utilizing database servers, are best backed-up using the related server's backup mechanism, as for any other database.
Contents
FAQ
Below are related FAQ entries.
Q: How do I backup my data?
A:It depends.
- If you're using the XML (default) backend, GnuCash makes local backups for you every time it saves your file. It does this by renaming the previous version of the file with a date-time-stamp and a new .gnucash suffix. For example, if your data file is named MyAccounts.gnucash, one of the backups might be named MyAccounts.gnucash.20140131150812.gnucash.
- If you're using the SQLite3 backend you should use a timed backup program to copy your account file in some way.
- If you're using either the MySQL or Postgresql backend, you should perform backups on the database in accordance with the recommended best practices appropriate to the server. We're not competent to advise you about this beyond recommending that you make backups.
- We strongly recommend that whatever backup plan you use includes a provision for offsite backups. A good option is one of the many internet storage facilities like DropBox, Google Drive, or Carbonite. Those are just popular examples; there are dozens of such services, and we can make no recommendation of one over another.
- There is a free 3rd party tool for creating GnuCash backups called BackupGnuCash. See http://wiki.gnucash.org/wiki/Published_tools.
- Restoring is simply a matter of removing the defective MyAccounts.gnucash and renaming one of the backup files to that, then starting Gnucash or using File>MyAccounts or File>Open and selecting MyAccounts.gnucash from the File Chooser.
- To restore from an off-disk backup, just copy MyAccounts.gnucash back into the directory where the original is.
Q: What are all these .gnucash and .log files filling up my directory?
- A: These are backup data files (".gnucash"; it was ".xac" in versions before 2.4) and log files (".log") that GnuCash creates to prevent data loss. Gnucash will remove them after a configurable amount of time (Preferences/General/"Days to retain log files"). In the normal case when your data file is ok and you don't need old versions of the file, you can remove these files safely.
- You should notice that the backup and log files have a format of <name>.YYYYMMDDHHMMSS.gnucash (or .log). These are backup (and log) files from your data file, <name>.
- Note that .log files are to be used only if you are using an XML backend for the book. With SQL storage, it is not recommended to replay the .log files. The data is always saved to the data store and the possibility of data loss is minimal in that case.
- This topic is covered more broadly in Backing Up and Recovering Data section of the User Guide.
Q: Why is my file name getting longer and longer?
- A: GnuCash creates a backup file by taking the current data file and adding the date/time to the end (YYYYMMDDHHMMSS.gnucash). Older versions up to 2.3.x still used the form YYYYMMDDHHMMSS.xac - from GnuCash's ancestor XAccountant. So if you're using a file named "Foo.gnucash", then you'll get backups of the form:
- Foo.gnucash.20100719100214.gnucash
- Now assume that instead of opening "Foo.gnucash" you open one of these backup files, you make changes to it and then save the file.
- For starters, this means you've just over-written the original backup file which is always a bad idea. Backups should never be changed.
- Secondly since you saved changes, GnuCash will create a backup file based the file you just changed using the same naming system: it adds a date/time extension. Since the file you saved already had such an extension, you end up with a backup file named:
- Foo.gnucash.20100719100214.gnucash.20100719112352.gnucash
- Repeating this process will add to the file name until it exceeds the operating system limits.
- The fix:
- 1) Don't open a backup file
- 1a) If you DO open a backup file, never simply save it out again, instead use Save As to give it a new name.
- 2) Make sure you're always using your base data file
- 3) If your base data file for some reason is bad, and you need to recover from a previous backup file, copy the backup file over your bad base file, for example:
- cp Foo.gnucash.20100719100214.gnucash.20100719112352.gnucash Foo.gnucash
- and then File -> Open the new file, Foo.gnucash.