1 # Updating the Database
3 There are many different ways to update your Nominatim database.
4 The following section describes how to keep it up-to-date using
5 an [online replication service for OpenStreetMap data](https://wiki.openstreetmap.org/wiki/Planet.osm/diffs)
6 For a list of other methods to add or update data see the output of
7 `nominatim add-data --help`.
10 If you have configured a flatnode file for the import, then you
11 need to keep this flatnode file around for updates.
13 ### Installing the newest version of Pyosmium
15 The replication process uses
16 [Pyosmium](https://docs.osmcode.org/pyosmium/latest/updating_osm_data.html)
17 to download update data from the server.
18 It is recommended to install Pyosmium via pip.
19 Run (as the same user who will later run the updates):
22 pip3 install --user osmium
25 ### Setting up the update process
27 Next the update process needs to be initialised. By default Nominatim is configured
28 to update using the global minutely diffs.
30 If you want a different update source you will need to add some settings
31 to `.env`. For example, to use the daily country extracts
32 diffs for Ireland from Geofabrik add the following:
34 # base URL of the replication service
35 NOMINATIM_REPLICATION_URL="https://download.geofabrik.de/europe/ireland-and-northern-ireland-updates"
36 # How often upstream publishes diffs (in seconds)
37 NOMINATIM_REPLICATION_UPDATE_INTERVAL=86400
38 # How long to sleep if no update found yet (in seconds)
39 NOMINATIM_REPLICATION_RECHECK_INTERVAL=900
41 To set up the update process now run the following command:
43 nominatim replication --init
45 It outputs the date where updates will start. Recheck that this date is
48 The `replication --init` command needs to be rerun whenever the replication
51 ### Updating Nominatim
53 Nominatim supports different modes how to retrieve the update data from the
54 server. Which one you want to use depends on your exact setup and how often you
55 want to retrieve updates.
57 These instructions are for using a single source of updates. If you have
58 imported multiple country extracts and want to keep them
59 up-to-date, [Advanced installations section](Advanced-Installations.md)
60 contains instructions to set up and update multiple country extracts.
62 #### Continuous updates
64 This is the easiest mode. Simply run the replication command without any
69 The update application keeps running forever and retrieves and applies
70 new updates from the server as they are published.
72 You can run this command as a simple systemd service. Create a service
73 description like that in `/etc/systemd/system/nominatim-updates.service`:
77 Description=Continuous updates of Nominatim
80 WorkingDirectory=/srv/nominatim
81 ExecStart=nominatim replication
82 StandardOutput=append:/var/log/nominatim-updates.log
83 StandardError=append:/var/log/nominatim-updates.error.log
89 WantedBy=multi-user.target
92 Replace the `WorkingDirectory` with your project directory. Also adapt user
93 and group names as required.
95 Now activate the service and start the updates:
98 sudo systemctl daemon-reload
99 sudo systemctl enable nominatim-updates
100 sudo systemctl start nominatim-updates
105 When the `--once` parameter is given, then Nominatim will download exactly one
106 batch of updates and then exit. This one-time mode still respects the
107 `NOMINATIM_REPLICATION_UPDATE_INTERVAL` that you have set. If according to
108 the update interval no new data has been published yet, it will go to sleep
109 until the next expected update and only then attempt to download the next batch.
111 The one-time mode is particularly useful if you want to run updates continuously
112 but need to schedule other work in between updates. For example, the main
113 service at osm.org uses it, to regularly recompute postcodes -- a process that
114 must not be run while updates are in progress. Its update script
120 # Switch to your project directory.
124 nominatim replication --once
125 if [ -f "/srv/nominatim/schedule-maintenance" ]; then
126 rm /srv/nominatim/schedule-maintenance
127 nominatim refresh --postcodes
132 A cron job then creates the file `/srv/nominatim/schedule-maintenance` once per night.
137 With the `--catch-up` parameter, Nominatim will immediately try to download
138 all changes from the server until the database is up-to-date. The catch-up mode
139 still respects the parameter `NOMINATIM_REPLICATION_MAX_DIFF`. It downloads and
140 applies the changes in appropriate batches until all is done.
142 The catch-up mode is foremost useful to bring the database up to speed after the
143 initial import. Give that the service usually is not in production at this
144 point, you can temporarily be a bit more generous with the batch size and
145 number of threads you use for the updates by running catch-up like this:
149 NOMINATIM_REPLICATION_MAX_DIFF=5000 nominatim replication --catch-up --threads 15
152 The catch-up mode is also useful when you want to apply updates at a lower
153 frequency than what the source publishes. You can set up a cron job to run
154 replication catch-up at whatever interval you desire.
157 When running scheduled updates with catch-up, it is a good idea to choose
158 a replication source with an update frequency that is an order of magnitude
159 lower. For example, if you want to update once a day, use an hourly updated
160 source. This makes sure that you don't miss an entire day of updates when
161 the source is unexpectely late to publish its update.
163 If you want to use the source with the same update frequency (e.g. a daily
164 updated source with daily updates), use the
165 continuous update mode. It ensures to re-request the newest update until it