Skip to content

Commit 7314fc7

Browse files
authored
Merge pull request #1411 from lonvia/update-script
Add a script for simple updating of a database
2 parents e15cd1a + c8dc330 commit 7314fc7

File tree

3 files changed

+542
-2
lines changed

3 files changed

+542
-2
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ User documentation is available on [the website](https://osm2pgsql.org/), some
5959
is stored in `docs/`. Pages on the OpenStreetMap wiki are known to be
6060
unreliable and outdated.
6161

62-
The [man page](docs/osm2pgsql.1) can be built from [source](docs/osm2pgsql.md)
63-
with `make man`. The result should be checked into the repository.
62+
The [osm2pgsql man page](docs/osm2pgsql.1) can be built from [source](docs/osm2pgsql.md)
63+
with `make man`. The [osm2pgsql-replication man page](docs/osm2pgsql-replication.1)
64+
has been built with:
65+
66+
argparse-manpage --pyfile scripts/osm2pgsql-replication --function get_parser
67+
68+
Results should be checked into the repository.
6469

6570
## Platforms targeted
6671

docs/osm2pgsql-replication.1

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
.TH osm2pgsql-replication "1" Manual
2+
.SH NAME
3+
osm2pgsql-replication
4+
.SH SYNOPSIS
5+
.B osm2pgsql-replication
6+
[-h] {init,update} ...
7+
.SH DESCRIPTION
8+
Update an osm2pgsql database with changes from a OSM replication server.
9+
.br
10+
11+
.br
12+
This tool initialises the updating process by looking at the import file
13+
.br
14+
or the newest object in the database. The state is then saved in a table
15+
.br
16+
in the database. Subsequent runs download newly available data and apply
17+
.br
18+
it to the database.
19+
.br
20+
21+
.br
22+
See the help of the 'init' and 'update' command for more information on
23+
.br
24+
how to use osm2pgsql\-replication.
25+
.SH OPTIONS
26+
27+
28+
.SS
29+
\fBSub-commands\fR
30+
.TP
31+
\fBosm2pgsql-replication\fR \fI\,init\/\fR
32+
Initialise the replication process.
33+
.TP
34+
\fBosm2pgsql-replication\fR \fI\,update\/\fR
35+
Download newly available data and apply it to the database.
36+
.SH OPTIONS 'osm2pgsql-replication init'
37+
usage: osm2pgsql-replication init [-h] [-q] [-v] [-d DB] [-U NAME] [-H HOST]
38+
[-P PORT] [--prefix PREFIX]
39+
[--osm-file FILE | --server URL]
40+
41+
Initialise the replication process.
42+
.br
43+
44+
.br
45+
There are two ways to initialise the replication process: if you have imported
46+
.br
47+
from a file that contains replication source information, then the
48+
.br
49+
initialisation process can use this and set up replication from there.
50+
.br
51+
Use the command '%(prog)s \-\-osm\-file <filename>' for this.
52+
.br
53+
54+
.br
55+
If the file has no replication information or you don't have the initial
56+
.br
57+
import file anymore then replication can be set up according to
58+
.br
59+
the data found in the database. It checks the planet_osm_way table for the
60+
.br
61+
newest way in the database and then queries the OSM API when the way was
62+
.br
63+
created. The date is used as the start date for replication. In this mode
64+
.br
65+
the minutely diffs from the OSM servers are used as a source. You can change
66+
.br
67+
this with the '\-\-server' parameter.
68+
69+
70+
71+
.TP
72+
\fB\-q\fR, \fB\-\-quiet\fR
73+
Print only error messages
74+
75+
.TP
76+
\fB\-v\fR, \fB\-\-verbose\fR
77+
Increase verboseness of output
78+
79+
.TP
80+
\fB\-d\fR DB, \fB\-\-database\fR DB
81+
Name of PostgreSQL database to connect to or conninfo string
82+
83+
.TP
84+
\fB\-U\fR NAME, \fB\-\-username\fR NAME
85+
PostgreSQL user name
86+
87+
.TP
88+
\fB\-H\fR HOST, \fB\-\-host\fR HOST
89+
Database server host name or socket location
90+
91+
.TP
92+
\fB\-P\fR PORT, \fB\-\-port\fR PORT
93+
Database server port
94+
95+
.TP
96+
\fB\-\-prefix\fR PREFIX
97+
Prefix for table names (default 'planet_osm')
98+
99+
.TP
100+
\fB\-\-osm\-file\fR FILE
101+
Get replication information from the given file.
102+
103+
.TP
104+
\fB\-\-server\fR URL
105+
Use replication server at the given URL (default: https://planet.openstreetmap.org/replication/minute)
106+
107+
.SH OPTIONS 'osm2pgsql-replication update'
108+
usage: osm2pgsql-replication update update [options] [-- param [param ...]]
109+
110+
Download newly available data and apply it to the database.
111+
.br
112+
113+
.br
114+
The data is downloaded in chunks of '\-\-max\-diff\-size' MB. Each chunk is
115+
.br
116+
saved in a temporary file and imported with osm2pgsql from there. The
117+
.br
118+
temporary file is normally deleted afterwards unless you state an explicit
119+
.br
120+
location with '\-\-diff\-file'. Once the database is up to date with the
121+
.br
122+
replication source, the update process exits with 0.
123+
.br
124+
125+
.br
126+
Any additional arguments to osm2pgsql need to be given after '\-\-'. Database
127+
.br
128+
and the prefix parameter are handed through to osm2pgsql. They do not need
129+
.br
130+
to be repeated. '\-\-append' and '\-\-slim' will always be added as well.
131+
132+
.TP
133+
\fBparam\fR
134+
Extra parameters to hand in to osm2pgsql.
135+
136+
.TP
137+
\fB\-\-diff\-file\fR FILE
138+
File to save changes before they are applied to osm2pgsql.
139+
140+
.TP
141+
\fB\-\-max\-diff\-size\fR \fI\,MAX_DIFF_SIZE\/\fR
142+
Maximum data to load in MB (default: 500MB)
143+
144+
.TP
145+
\fB\-\-osm2pgsql\-cmd\fR \fI\,OSM2PGSQL_CMD\/\fR
146+
Path to osm2pgsql command (default: osm2pgsql)
147+
148+
.TP
149+
\fB\-\-once\fR
150+
Run updates only once, even when more data is available.
151+
152+
.TP
153+
\fB\-q\fR, \fB\-\-quiet\fR
154+
Print only error messages
155+
156+
.TP
157+
\fB\-v\fR, \fB\-\-verbose\fR
158+
Increase verboseness of output
159+
160+
.TP
161+
\fB\-d\fR DB, \fB\-\-database\fR DB
162+
Name of PostgreSQL database to connect to or conninfo string
163+
164+
.TP
165+
\fB\-U\fR NAME, \fB\-\-username\fR NAME
166+
PostgreSQL user name
167+
168+
.TP
169+
\fB\-H\fR HOST, \fB\-\-host\fR HOST
170+
Database server host name or socket location
171+
172+
.TP
173+
\fB\-P\fR PORT, \fB\-\-port\fR PORT
174+
Database server port
175+
176+
.TP
177+
\fB\-\-prefix\fR PREFIX
178+
Prefix for table names (default 'planet_osm')
179+
180+
.SH DISTRIBUTION
181+
The latest version of osm2pgsql\-replication may be downloaded from
182+
.UR <<UNSET \-\-url OPTION>>
183+
.UE

0 commit comments

Comments
 (0)