Undoing deletions

From OpenStreetMap Wiki
(Redirected from Undoing Deletions)
Jump to navigation Jump to search

two merging arrows

It has been proposed that this page or section be merged with Change rollback. (Discuss)

This article describe undoing deletion. Please refer to article Change rollback for general rollback.

Before undoing edits of other users please try to contact them first.

Undoing deletions while editing

In general you can undo any kind of accidental editing mistake, including deletions, by pressing Ctrl+Z (in JOSM, Potlatch or Merkaartor). This gets used a lot by even the most experienced OpenStreetMap contributors.

But what if you've done an upload?

Undoing deletions after upload

So, you deleted a large chunk of the map, and then uploaded by mistake?! What can be done to get the data back on the server again?

Method 1: Use JOSM undelete plugin

See JOSM/Plugins/Undelete (or, more the general option, JOSM/Plugins/Reverter)

Method 2: Undeleting single nodes with Level 0

You can use the low-level editor Level 0 to undelete a node: see Level0#Undelete a node.

Method 3: Use restore-version.py (Command line)

Follow the instructions on the GitHub repo. Example: You can run restore-version.py w12345 -1, where the first argument is an object type and id: n123 for nodes, w123 for ways and r123 for relations. Or you can simply pass an URL from osm.org website.

Method 4: I have a copy saved from before I deleted stuff

This method assumes that you are using JOSM, and that you have a saved copy of the data on your local machine (let's say, "data.osm"). When you saved the data is important. If it was before you deleted the items, then this is the easiest to recover. If it was after you deleted the items, but before you uploaded, then it is still possible. If the only copy you have is after you uploaded, then you cannot recover using this method

There is an important lesson here: as with any computer application, save locally as you go along, as well as uploading to the central server.

This should be fairly straightforward to recover. We want to tell the server that the items IDs that have been deleted are now modified. This will undelete them on the server.

  1. Start JOSM and download the affected area from the server. You can do this in small areas if you like.
  2. Load your "data.osm" from the local disk. Hopefully you will now see all data back again.
  3. Try and upload. Nothing should be available for upload, but if it is you will need to work out what it is and whether you really want to upload it.
  4. Use the select tool to select the area that was affected.
  5. Add a new tag to all this data, that does not clash with any existing tags. Maybe something like "ignore=me".
  6. Delete this new tag. All items you added this tag to are now marked as "modified" in JOSM, and are candidates for upload.
  7. Upload the data.
  8. Restart JOSM and download the affected area to check it has uploaded correctly.
  9. Repeat from 1 for any additional areas that need to be corrected.

Warning: this will set the items that you upload to the server to be the same as you have on disk. If your local copy is quite old, then by doing this you may revert changes that other people had made to the data on the server. This is another reason to keep saving locally as you are editing!

Manual recovery without tool support

Recover deleted Relations

For this example I'm using the relation 49903 for which I did a restore.

  1. Open the history in the browser: https://www.openstreetmap.org/browse/relation/49903/history
    1. if the relation does have a lot of versions step 1. may fail with an error message like (sorry, it take too much time...). You can directly open a specific version by using https://api.openstreetmap.org/api/0.6/relation/<Relation ID>/<Version number>
  2. Check that all ways of the relation still exist. If some of the ways are also deleted it's best to recover these first. Please be extra careful with this step. Had the ways been deleted for a good reason? Do more accurate ways exist? If so it might be a good Idea to use these in the recovered version instead. In my example this is the case.
  3. Download the XML source using the api url and save with .osm extension
  4. Open the file in a text editor. In my case the delete was in version 18, I want to recover version 17. I delete all old relation blocks, keep only version 17 and 18.
  5. Replace the line with the relation tag of the version you want to keep with the most current one. Don't forget to remove the closing slash in case the last version was a delete.
  6. Add the attribute action="modify" to the relation
  7. As in my case some ways need to be replaced - so I also removed these entries (it's easier to do this after opening in JOSM)
  8. Save the file and open it in JOSM
  9. If possible, download all members, run update data (CTRL+U) to check for any conflicts and deleted ways
  10. Upload your change in JOSM. Voilà, the relation is back.
  11. In my case I now downloaded the relation members and selected new ways to fill the gaps the previously deleted ways had left.

Recover deleted nodes

See Manually undelete node

Undoing other people's uploads

Now what if somebody else deleted your edits and you have no way of finding exactly which way/node/relation was deleted? Then you need to find that in the history. See Find the id of a deleted node