]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/templates/default/planetdump.erb
Switch to using planet-dump-ng instead of planetdump
[chef.git] / cookbooks / planet / templates / default / planetdump.erb
1 #!/bin/bash
2
3 # Exit on error
4 set -e
5
6 # Get the name of the file and the expected pattern
7 file="$1"
8 pattern="^osm-([0-9]{4}-[0-9]{2}-[0-9]{2})\.dmp$"
9
10 # Give up now if the file isn't a database dump
11 [[ $file =~ $pattern ]] || exit 0
12
13 # Save the date from the file name
14 date="${BASH_REMATCH[1]}"
15
16 # Check the lock
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"
20         exit 1
21     else
22         rm /tmp/planetdump.lock
23     fi
24 fi
25
26 # Create Lock
27 echo $$ > /tmp/planetdump.lock
28
29 # Change to working directory
30 cd /store/planetdump
31
32 # Cleanup
33 rm -rf users
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
38
39 # Run the dump
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"
45
46 # Move XML dumps into place
47 for file in "changesets-${date}.osm.bz2" "planet-${date}.osm.bz2" "history-${date}.osm.bz2"
48 do
49     md5sum "#{file}" > "#{file}.md5"
50     mv "${file}" "${file}.md5" "/store/planet/planet"
51 done
52
53 # Move PBF dumps into place
54 for file in "planet-${date}.osm.pbf" "history-${date}.osm.pbf"
55 do
56     md5sum "#{file}" > "#{file}.md5"
57     mv "${file}" "${file}.md5" "/store/planet/pbf"
58 done
59
60 # Release lock
61 rm /tmp/planetdump.lock