9

In QGIS 3.10.12, I duplicated a GeoPackage vector layer. I made a lot of changes to the new (duplicate) layer and accidentally saved it. Now the original layer has been wiped. The undo button is disabled for the duplicate layer so I cannot undo the changes. As it turns out, this is a QGIS feature.

I don't have a backup or shadow copy of the geo-package.

QGIS is still running. I have not closed it yet. Is there a way of restoring my data?

Such as temporary files that may have been saved somewhere (in \ApplicationData\ or Temp folder, for example).

I tried Current Edits > Rollback For All Layers, but nothing happened.

6
  • 6
    If the .wal file still exists it is possible that edits have not been written into .gpkg file yet. Copy just the .gpkg file into another directory, rename it, open and see in which state it is.
    – user30184
    Nov 29, 2020 at 18:59
  • 2
    @user30184 Thanks a lot, it worked. I had made copies of the three files immediately after the disaster, but I was planning on restoring all three of them. It was a mistake. As you correctly said, only the geo-package file should be restored, not the two cache files. Please post your comment as an answer so I can upvote and choose it as the correct answer. Nov 29, 2020 at 19:32
  • 3
    Please don't post an answer in the question. You can answer your own question here.
    – Vince
    Nov 29, 2020 at 21:16
  • 1
    You can write an answer and get some credits. Add a link to sqlite.org/wal.html and warn that once checkpointing has happened there is no return.
    – user30184
    Nov 29, 2020 at 21:28
  • 2
    A good idea is always to keep all original data in a folder that is write protected, so you are forced to use a copy for editing. A good concept of data management does help a lot
    – Babel
    Nov 30, 2020 at 7:03

1 Answer 1

12

The original answer by @user30184:

If the .wal file still exists it is possible that edits have not been written into .gpkg file yet. Copy just the .gpkg file into another directory, rename it, open and see in which state it is.

Some tips: QGIS stores the changes in the cache files before applying them to the geo-package. If you have the same (or a similar) problem, don't close QGIS. Keep it running, don't do anything, no edits, no saves, nothing. Just make a copy of the gpkg-file immediately. Don't try making a compressed file using zip applications, because you will receive an error message akin to:

Cannot read the file because it is currently being used by another application.

Just make a copy.

Here's more information on the issue: https://issues.qgis.org/issues/19489

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.