Skip to content

Commit c9c6e40

Browse files
committed
add manpage for osm2pgsql-replication
The page has been procuded with argparse-manpage.
1 parent 5468b37 commit c9c6e40

File tree

2 files changed

+194
-9
lines changed

2 files changed

+194
-9
lines changed

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

osm2pgsql-replication

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import logging
2626
import sys
2727
import subprocess
2828
import tempfile
29+
from textwrap import dedent
2930
import traceback
3031
from pathlib import Path
3132
import urllib.request as urlrequest
@@ -117,6 +118,8 @@ def update_replication_state(conn, table, seq, date):
117118

118119
def init(conn, args):
119120
"""\
121+
Initialise the replication process.
122+
120123
There are two ways to initialise the replication process: if you have imported
121124
from a file that contains replication source information, then the
122125
initialisation process can use this and set up replication from there.
@@ -254,8 +257,9 @@ def update(conn, args):
254257

255258
return 0
256259

257-
def get_args():
260+
def get_parser():
258261
parser = ArgumentParser(description=__doc__,
262+
prog='osm2pgsql-replication',
259263
formatter_class=RawDescriptionHelpFormatter)
260264
subs = parser.add_subparsers(title='available commands', dest='subcommand')
261265

@@ -283,7 +287,7 @@ def get_args():
283287
# Arguments for init
284288
cmd = subs.add_parser('init', parents=[default_args],
285289
help=init.__doc__.split('\n', 1)[0],
286-
description=init.__doc__,
290+
description=dedent(init.__doc__),
287291
formatter_class=RawDescriptionHelpFormatter,
288292
add_help=False)
289293
grp = cmd.add_argument_group('Replication source arguments')
@@ -299,7 +303,7 @@ def get_args():
299303
cmd = subs.add_parser('update', parents=[default_args],
300304
usage='%(prog)s update [options] [-- param [param ...]]',
301305
help=update.__doc__.split('\n', 1)[0],
302-
description=update.__doc__,
306+
description=dedent(update.__doc__),
303307
formatter_class=RawDescriptionHelpFormatter,
304308
add_help=False)
305309
cmd.set_defaults(handler=update)
@@ -315,18 +319,16 @@ def get_args():
315319
cmd.add_argument('--once', action='store_true',
316320
help='Run updates only once, even when more data is available.')
317321

322+
return parser
323+
324+
def main():
325+
parser = get_parser()
318326
args = parser.parse_args()
319327

320328
if args.subcommand is None:
321329
parser.print_help()
322330
exit(1)
323331

324-
return args
325-
326-
327-
def main():
328-
args = get_args()
329-
330332
logging.basicConfig(stream=sys.stderr,
331333
format='{asctime} [{levelname}]: {message}',
332334
style='{',

0 commit comments

Comments
 (0)