6 # Get the name of the file and the expected pattern
8 pattern="^osm-([0-9]{4}-[0-9]{2}-[0-9]{2})\.dmp$"
10 # Give up now if the file isn't a database dump
11 [[ $file =~ $pattern ]] || exit 0
13 # Save the date from the file name
14 date="${BASH_REMATCH[1]}"
17 if [ -f /tmp/planetdump.lock ]; then
18 if [ "$(ps -p `cat /tmp/planetdump.lock` | wc -l)" -gt 1 ]; then
19 echo "Error: Another planetdump is running"
22 rm /tmp/planetdump.lock
27 echo $$ > /tmp/planetdump.lock
31 rm /tmp/planetdump.lock
37 # Change to working directory
42 rm -rf changesets changeset_tags
43 rm -rf nodes node_tags
44 rm -rf ways way_tags way_nodes
45 rm -rf relations relation_tags relation_members
48 time nice -n 19 /store/planet-dump-ng/planet-dump-ng \
49 -c "pbzip2 -c" -f "${file}" --dense-nodes=1 \
50 -C "changesets-${date}.osm.bz2" \
51 -x "planet-${date}.osm.bz2" -X "history-${date}.osm.bz2" \
52 -p "planet-${date}.osm.pbf" -P "history-${date}.osm.pbf"
54 # Move XML dumps into place
55 for file in "changesets-${date}.osm.bz2" "planet-${date}.osm.bz2" "history-${date}.osm.bz2"
57 md5sum "#{file}" > "#{file}.md5"
58 mv "${file}" "${file}.md5" "/store/planet/planet"
61 # Move PBF dumps into place
62 for file in "planet-${date}.osm.pbf" "history-${date}.osm.pbf"
64 md5sum "#{file}" > "#{file}.md5"
65 mv "${file}" "${file}.md5" "/store/planet/pbf"