Difference between revisions of "Backup"

From GnuCash
Jump to: navigation, search
(moved .log files entry from the faq)
m ({{URL:FP|docs.}}en/latest/ -> {{URL:FP-docs}})
 
(31 intermediate revisions by 6 users not shown)
Line 1: Line 1:
How one creates a backup of GnuCash data depends mostly on the type of backend used to store the book information.
+
{| class="wikitable" style="margin: auto;"
 +
! scope="row"|Languages
 +
| [[Zh-hans/翻译|简体中文]]
 +
| | [[He/{{PAGENAME:גיבוי}}|עִברִית]]
 +
|}
  
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.
+
== Introduction ==
  
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.
+
Backing up your GnuCash data is important to protect and secure your financial data from potential equipment failure or data corruption.  
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 [https://bugzilla.gnome.org/show_bug.cgi?id=795393 bug].
 
  
Other SQL-type backends, utilizing database servers, are best backed-up using the related server's backup mechanism, as for any other database.
+
GnuCash does not directly provide back up services for this type of failure. Recovering data in the event of equipment failure depends on having a robust backup process that includes offsite storage of up-to-date copies of your data. You are strongly advised to implement such processes.
  
Below are related FAQ entries.
+
==GnuCash Data Files==
  
===='''Q:''' How do I backup my data?====
+
Determining what are the GnuCash data files depends on the type of backend used to store the book information.
'''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 [https://www.dropbox.com/ DropBox], [https://drive.google.com/ Google Drive], or [http://www.carbonite.com/ 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.
+
;XML (default): GnuCash makes local backups for you every time it saves your file. You must save your file (by clicking the Save button or using Autosave functionality in the preferences). 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.
:* 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?====
+
;SQL: GnuCash automatically saves any changes to the sql data stores as you work on your book. For this reason, there are no backup files with the SQL backends. Note that, even though there are no automatic backup files generated when using SQLite backend, GnuCash will still generate .log files with changes. While it might possible to replay .log files on top of an sql book, this is not officially supported and in some cases may even have adverse effects. One option, in case of data loss, would be to convert the sqlite book to XML and replay the transactions log on top of that and then re-save the file again with SQLite. More info in the related [https://bugzilla.gnome.org/show_bug.cgi?id=795393 bug].
  
:'''A:''' These are backup [[File|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.
+
:;SQLite3: You should use a timed backup program to copy your account file in some way, or make manual file copies.
 +
:;MySQL or Postgresql: 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.
  
: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>.
+
As noted above, it is strongly recommended that whatever backup plan you use includes a provision for '''offsite backups'''. Imagine a fire in your home. A good option is one of the many ''cloud storage services'' like [https://www.dropbox.com/ DropBox], [https://drive.google.com/ Google Drive], or [http://www.carbonite.com/ Carbonite]. Those are just popular examples; there are dozens of such services, and we can make no recommendation of one over another.
  
: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.
+
:There is a free 3rd party tool for creating GnuCash backups called BackupGnuCash. See [[Published_tools]].
: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.
+
 
 +
==Related Files==
 +
 
 +
Of course, you should save your actual data files, although it is up to you whether you save the backup and log files (''.gnucash'' or ''.xac'', ''.log''). See above for more on the subject.
 +
 
 +
In addition to the actual data file, however, there are a number of files that store your preferences, user interface settings, and saved reports. It is advisable to back these resources up as well.
 +
 
 +
[[Configuration Locations]] identifies the OS-dependent locations of all the different files, as well as their names.
 +
 
 +
Additional information you need to save includes ''general configuration'' data, ''preferences'' data, ''theming'' data, and ''online banking'' settings.
 +
 
 +
:;General Configuration data:
 +
::;Gnucash 3.0 and newer: The contents of [[Configuration Locations#GNC_DATA_HOME|GNC_DATA_HOME]] and [[Configuration Locations#GNC_CONFIG_HOME|GNC_CONFIG_HOME]].
 +
::;Gnucash 2.x and older:
 +
:::;Linux: [[Configuration Locations#HOME|HOME]]/.gnucash - most of your preferences, adjusted report settings, column withs, window positions, etc.
 +
:::;Windows: [[Configuration Locations#HOME|HOME]]\.gnucash
 +
:::;{{Mac}}: HOME/Library/Application Support/Gnucash
 +
 
 +
:;Preferences data
 +
:Preferences from <tt>Edit->Preferences</tt> (like [[#Q: I have deleted a gnucash file from my computer. How can I remove that file from the File menu's short list (MRU) as well ?|history]], sign reversals, auto save interval, etc.) are stored using '''GSettings''' (for GnuCash 2.6 and newer) or '''GConf''' (for GnuCash 2.4 and older).
 +
::;[[Configuration Locations#GSettings|GSettings]]:
 +
:::;Linux and similar: GSettings uses ''dconf'' as backend. You can use the <tt>dconf</tt> tool to dump all the preferences:
 +
::::;Since Gnucash 4.7: <syntaxhighlight lang="sh">dconf dump /org/gnucash/GnuCash/</syntaxhighlight>
 +
::::;Before: <syntaxhighlight lang="sh">dconf dump /org/gnucash/</syntaxhighlight>
 +
::::;Note: These settings are usually not available via dconf in [[Flatpak]] installations.<ref>[{{URL:FP-docs}}sandbox-permissions.html#dconf-access dconf-access in Sandbox Permissions]</ref> Please see [[Configuration Locations#GSettings|GSettings]] under [[Configuration Locations]]
 +
:::;Windows: Gsettings uses the Windows ''registry'' as backend. You can make a backup of the
 +
::::;Since Gnucash 4.7: <tt>HKEY_CURRENT_USER\Software\GSettings\org\gnucash\GnuCash\</tt>
 +
::::;Before: <tt>HKEY_CURRENT_USER\Software\GSettings\org\gnucash\</tt>
 +
:::: registry key using the <tt>regedit</tt> command ('''Registry Editor''').
 +
:::;{{Mac}}: GSettings uses the system's native ''defaults''. You can use the <tt>defaults</tt> tool to dump all the preferences: <syntaxhighlight lang="sh">defaults read -app Gnucash</syntaxhighlight>
 +
::;GConf: The GConf settings are stored in [[Configuration Locations#HOME|HOME]]/.gconf/apps/gnucash/
 +
 
 +
:;Online Banking data:
 +
:If you are using [[AqBanking]] online banking, the stored settings are placed in a specific folder.
 +
::;Linux and {{Mac}}: <tt>[[Configuration Locations#HOME|HOME]]/.[aq]banking</tt> holds your online banking settings. In older versions it was named ''.banking'' but ''.aqbanking'' is the current name.
 +
::;Windows: '''[[Configuration Locations#HOME|HOME]]\aqbanking'''
 +
 
 +
:;Theming Data
 +
::If you
 +
::: made changes to the '''GTK configuration''' (<tt>settings.ini</tt> or <tt>gtk.css</tt>) or
 +
::: have installed custom '''themes''' and/or icon themes
 +
:: you may want to back up the contents of the following directories as well: [[Configuration Locations#GTK_DATA_HOME|GTK_DATA_HOME]], [[Configuration Locations#GTK_CONFIG_HOME|GTK_CONFIG_HOME]], [[Configuration Locations#USER_CONFIG_HOME|USER_CONFIG_HOME]]/themes and [[Configuration Locations#USER_CONFIG_HOME|USER_CONFIG_HOME]]/icons.
 +
:: For Gnucash 3.x [[GTK3]] or
 +
:: older versions [[GTK2]] have more info on when these directories are used.
 +
 
 +
==Restoring==
 +
 
 +
Restoring a data file is simply a matter of removing the defective file and renaming one of the backup files to that, then starting GnuCash or using File>Open and selecting the file from the File Chooser.
 +
Do note that, if you simply run GnuCash, it will always open the file that was last opened (if any). This may be important if you tend to open different book files.
 +
 
 +
To restore from an offsite backup, just copy the remote file back into the directory where the original is.
 +
 
 +
=== {{Mac}} ===
 +
 
 +
On Macs, a GnuCash file cannot be opened by clicking on it.  GnuCash *always* opens the last-used data file.
 +
To swap files on a Mac, one has to use File -> Open and navigate to the file one wants to use.
 +
 
 +
Also, dragging the .gnucash file over the Gnucash app will not Open the file, unlike what is normally the case for Mac apps. You still need to use the File Open option from the GnuCash menu.
 +
 
 +
[[category:Help]] [[category:Usage]]

Latest revision as of 10:19, 6 March 2024

Languages 简体中文 עִברִית

Introduction

Backing up your GnuCash data is important to protect and secure your financial data from potential equipment failure or data corruption.

GnuCash does not directly provide back up services for this type of failure. Recovering data in the event of equipment failure depends on having a robust backup process that includes offsite storage of up-to-date copies of your data. You are strongly advised to implement such processes.

GnuCash Data Files

Determining what are the GnuCash data files depends on the type of backend used to store the book information.

XML (default)
GnuCash makes local backups for you every time it saves your file. You must save your file (by clicking the Save button or using Autosave functionality in the preferences). 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.
SQL
GnuCash automatically saves any changes to the sql data stores as you work on your book. For this reason, there are no backup files with the SQL backends. Note that, even though there are no automatic backup files generated when using SQLite backend, GnuCash will still generate .log files with changes. While it might possible to replay .log files on top of an sql book, this is not officially supported and in some cases may even have adverse effects. One option, in case of data loss, would be to convert the sqlite book to XML and replay the transactions log on top of that and then re-save the file again with SQLite. More info in the related bug.
SQLite3
You should use a timed backup program to copy your account file in some way, or make manual file copies.
MySQL or Postgresql
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.

As noted above, it is strongly recommended that whatever backup plan you use includes a provision for offsite backups. Imagine a fire in your home. A good option is one of the many cloud storage services 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 Published_tools.

Related Files

Of course, you should save your actual data files, although it is up to you whether you save the backup and log files (.gnucash or .xac, .log). See above for more on the subject.

In addition to the actual data file, however, there are a number of files that store your preferences, user interface settings, and saved reports. It is advisable to back these resources up as well.

Configuration Locations identifies the OS-dependent locations of all the different files, as well as their names.

Additional information you need to save includes general configuration data, preferences data, theming data, and online banking settings.

General Configuration data
Gnucash 3.0 and newer
The contents of GNC_DATA_HOME and GNC_CONFIG_HOME.
Gnucash 2.x and older
Linux
HOME/.gnucash - most of your preferences, adjusted report settings, column withs, window positions, etc.
Windows
HOME\.gnucash
macOS
HOME/Library/Application Support/Gnucash
Preferences data
Preferences from Edit->Preferences (like history, sign reversals, auto save interval, etc.) are stored using GSettings (for GnuCash 2.6 and newer) or GConf (for GnuCash 2.4 and older).
GSettings
Linux and similar
GSettings uses dconf as backend. You can use the dconf tool to dump all the preferences:
Since Gnucash 4.7
dconf dump /org/gnucash/GnuCash/
Before
dconf dump /org/gnucash/
Note
These settings are usually not available via dconf in Flatpak installations.[1] Please see GSettings under Configuration Locations
Windows
Gsettings uses the Windows registry as backend. You can make a backup of the
Since Gnucash 4.7
HKEY_CURRENT_USER\Software\GSettings\org\gnucash\GnuCash\
Before
HKEY_CURRENT_USER\Software\GSettings\org\gnucash\
registry key using the regedit command (Registry Editor).
macOS
GSettings uses the system's native defaults. You can use the defaults tool to dump all the preferences:
defaults read -app Gnucash
GConf
The GConf settings are stored in HOME/.gconf/apps/gnucash/
Online Banking data
If you are using AqBanking online banking, the stored settings are placed in a specific folder.
Linux and macOS
HOME/.[aq]banking holds your online banking settings. In older versions it was named .banking but .aqbanking is the current name.
Windows
HOME\aqbanking
Theming Data
If you
made changes to the GTK configuration (settings.ini or gtk.css) or
have installed custom themes and/or icon themes
you may want to back up the contents of the following directories as well: GTK_DATA_HOME, GTK_CONFIG_HOME, USER_CONFIG_HOME/themes and USER_CONFIG_HOME/icons.
For Gnucash 3.x GTK3 or
older versions GTK2 have more info on when these directories are used.

Restoring

Restoring a data file is simply a matter of removing the defective file and renaming one of the backup files to that, then starting GnuCash or using File>Open and selecting the file from the File Chooser. Do note that, if you simply run GnuCash, it will always open the file that was last opened (if any). This may be important if you tend to open different book files.

To restore from an offsite backup, just copy the remote file back into the directory where the original is.

macOS

On Macs, a GnuCash file cannot be opened by clicking on it. GnuCash *always* opens the last-used data file. To swap files on a Mac, one has to use File -> Open and navigate to the file one wants to use.

Also, dragging the .gnucash file over the Gnucash app will not Open the file, unlike what is normally the case for Mac apps. You still need to use the File Open option from the GnuCash menu.