|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.
- 1 Undoing deletions while editing
- 2 Undoing deletions after upload
- 2.1 Method 1: Use Potlatch 1 revert function (easy!)
- 2.2 Method 2: Use JOSM revert plugin (also easy!)
- 2.3 Method 3: Undeleting single nodes with Level 0
- 2.4 Method 4: Use restore-version.py
- 2.5 Method 5: I have a copy saved from before I deleted stuff
- 2.6 Manual recovery without tool support
- 3 Undoing other people's uploads
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 Potlatch 1 revert function (easy!)
It is not possible to undelete objects using Potlatch 2 or iD
Method 2: Use JOSM revert plugin (also easy!)
Method 3: 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 4: Use restore-version.py
You would need ids of deleted objects. Clone this github repo (or download a raw restore-version.py file). Then 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 5: 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.
- Start JOSM and download the affected area from the server. You can do this in small areas if you like.
- Load your "data.osm" from the local disk. Hopefully you will now see all data back again.
- 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.
- Use the select tool to select the area that was affected.
- Add a new tag to all this data, that does not clash with any existing tags. Maybe something like "ignore=me".
- Delete this new tag. All items you added this tag to are now marked as "modified" in JOSM, and are candidates for upload.
- Upload the data.
- Restart JOSM and download the affected area to check it has uploaded correctly.
- 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
As the current (TODO: really, still? What about the JOSM reverter or undelete plugin?) tools provide no easy way to recover a deleted relation this is a bit tricky. If you are not sure you can do this without breaking more stuff then ask for help on the mailing list.
For this example I'm using the relation 49903 for which I did a restore.
- Open the history in the browser: http://www.openstreetmap.org/browse/relation/49903/history
- 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 http://api.openstreetmap.org/api/0.6/relation/<Relation ID>/<Version number>
- 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.
- Download the XML source
- 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.
- 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.
- Add the attribute action="modify" to the relation
- As in my case some ways need to be replaced - so I also removed these entries.
- Save the file and open it in JOSM
- Upload your change in JOSM. Voilà, the relation is back.
- 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
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