osmprj sync
osmprj sync [SOURCE...] [-v]
Downloads and imports all registered sources, or only the named subset. On first run it performs a full import; on subsequent runs it applies incremental updates via osm2pgsql-replication.
Options
SOURCE...— One or more source names to sync. Defaults to all sources if omitted.-v/--verbose— Streamosm2pgsqllog output to the terminal in addition to writing it to the log file.
How it works
- Classify — Checks the database to determine which sources have already been imported and have replication initialised (update mode) vs. those that need a fresh import.
- Download — For each Geofabrik source that needs a fresh import and has not been downloaded yet, streams the PBF file to the OS cache directory with a progress bar. MD5 checksums are verified against Geofabrik's sidecar files. Already-downloaded files are skipped.
- Tune — Automatically selects
osm2pgsqlflags based on your system RAM, PBF file size, and whether the storage is SSD:- Uses
--flat-nodesfor large files (≥ 8 GB on SSD, ≥ 30 GB on HDD). - Sets
--cacheto up to 66% of system RAM for smaller files.
- Uses
- Import — Runs
osm2pgsql --create --slim --output=flexfor each fresh source. - Replication init — Runs
osm2pgsql-replication initimmediately after each fresh import. - Update — For sources already in update mode, runs
osm2pgsql-replication updateto apply changes since the last sync.
Logs for each source are written to ./logs/<source-name>.log (configurable via log_dir).
Examples
# Sync everything
osmprj sync
# Sync a specific source
osmprj sync germany
# Sync with verbose osm2pgsql output
osmprj sync -v