Feature request #12684
QGIS should backup settings before save
|Pull Request or Patch supplied:||No||Resolution:|
|Easy fix?:||No||Copied to github as #:||20791|
As per title - QGIS app should make a backup copy of settings file(s) before writing out a new configuration.
Rationale - during a quite long georeferencing session with QGIS 2.9.0 (8b37ea2), at some point something went south and all QGIS settings were lost. First I observed missing WMS providers during the same work session, then, after restart of QGIS, I was greeted with a pristine, first time run QGIS configuration. Costed me all WMS service providers with their configuration :( Afterwards I haven't been able to reproduce configuration loss thus this is a wish on automatic backups not a bug report on configuration loss.
#2 Updated by marisn - almost 5 years ago
Regis Haubourg wrote:
Hi, that's strange, here ini files are saved at every change. On what platform are you working? Did you configure a --configpath to move settings location?
"ini files" - I assume you are on Windows. I use a ~AMD64 Gentoo Linux.
I haven't been looking into --configpath option thus can not comment if it helps to fix the issue.
I just (again!) lost all QGIS settings with all WMS services. Again georeferencing. Apparently I must back-up all settings files before using georeferencer.
#3 Updated by marisn - almost 5 years ago
I managed to track down the mechanism behind the loss of QGIS settings. The root cause is insecure writing of configuration files. Current logic is "open old configuration file for writing; truncate it; write new configuration". If for some reason writing of new configuration fails, user is left with a truncated or partially written configuration file. Georeferencer is not to blame here (gereferencing simply quite often might go south and fill the disk causing subsequent writes to fail).
The correct sequence should be: write new configuration file; on success, rename to old file.
Such approach would allow QGIS configuration files to exist in two states - old or new but never in a corrupted one.
Of course - even better question is - should QGIS write to disk WMS settings each time some other of its application settings has been changed (i.e. window position, recent used files etc.).
Analysis of this issue is based on file observations not on code analysis.
#5 Updated by marisn - almost 5 years ago
I see :( As I again lost all QGIS settings + all my WMS settings, I find it a bit sad.
According to Qt bug tracker, QSettings storage is atomic starting from 5.4.0. One commenter also mentions a high speed penalty for writing large settings files. https://bugreports.qt.io/browse/QTBUG-21739
I created a separate wish for moving connection settings out of main QGIS settings: #13496
Jürgen, as I don't care so much for the rest of QGIS settings except connection ones, feel free to close this issue if implementing a workaround seems too much work. I would prefer a solution proposed in #13496