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
29 # Change to working directory
34 rm -rf changesets changeset_tags
35 rm -rf nodes node_tags
36 rm -rf ways way_tags way_nodes
37 rm -rf relations relation_tags relation_members
40 time nice -n 19 /store/planet-dump-ng/planet-dump-ng \
41 -c "pbzip2 -c" -f "${file}" --dense-nodes=1 \
42 -C "changesets-${date}.osm.bz2" \
43 -x "planet-${date}.osm.bz2" -X "history-${date}.osm.bz2" \
44 -p "planet-${date}.osm.pbf" -P "history-${date}.osm.pbf"
46 # Move XML dumps into place
47 for file in "changesets-${date}.osm.bz2" "planet-${date}.osm.bz2" "history-${date}.osm.bz2"
49 md5sum "#{file}" > "#{file}.md5"
50 mv "${file}" "${file}.md5" "/store/planet/planet"
53 # Move PBF dumps into place
54 for file in "planet-${date}.osm.pbf" "history-${date}.osm.pbf"
56 md5sum "#{file}" > "#{file}.md5"
57 mv "${file}" "${file}.md5" "/store/planet/pbf"
61 rm /tmp/planetdump.lock