Hi,
I managed to set up an OSM-Sever, updating itself per minute-replicate by following this tutorial: http://wiki.openstreetmap.org/wiki/DE:HowTo_minutely_hstore
Now I would like to change the updates from minutely to daily (or hourly), because the load of using minutely diffs is a bit heavy on my server. I would prefer to automatically update the database in the evening with a daily diff, so that the load keeps small during the day. Could someone give me a hint, how to change the “load-next” script, currently used for minutely updates to load and import daily updates. If this is not possible, would it be possible to change it to the hour-replicate?
configuration.txt
# The URL of the directory containing change files.
baseUrl=http://planet.openstreetmap.org/minute-replicate/
# Defines the maximum time interval in seconds to download in a single invocation.
# Setting to 0 disables this feature.
# 6 hours
maxInterval = 21600
load-next script to initiate the update
#!/bin/bash
# loads the diffs for the interval read from configuration.txt
# may be executed every 5 minutes or so
PIDFILE=`basename $0`.pid
OSMOSIS=/opt/osmosis/bin/osmosis
OSM2PGSQL=/usr/local/bin/osm2pgsql
STYLE=/usr/local/share/osm2pgsql/default.style
# java proxy settings for osmosis
# JAVACMD_OPTIONS="-Dhttp.proxyHost=ha-proxy.esi -Dhttp.proxyPort=8080"
# export JAVACMD_OPTIONS
OSMOSISLOG=logs/osmosis.log
PSQLLOG=logs/osm2pgsql.log
EXPIRYLOG=logs/expiry.log
RUNLOG=logs/run.log
HOST=/var/run/postgresql
DB=gis
PREFIX=planet
USER=gis
CURRENT=/tmp/osm-load-next.$$.osc
EXPIRE=0
m_info()
{
echo "[`date +"%Y-%m-%d %H:%M:%S"`] $$ $1" >> "$RUNLOG"
}
m_error()
{
echo "[`date +"%Y-%m-%d %H:%M:%S"`] $$ [error] $1" >> "$RUNLOG"
m_info "resetting state"
/bin/cp last.state.txt state.txt
rm "$PIDFILE"
exit 1
}
m_ok()
{
echo "[`date +"%Y-%m-%d %H:%M:%S"`] $$ $1" >> "$RUNLOG"
}
getlock()
{
if [ -s $PIDFILE ]; then
if [ "$(ps -p `cat $PIDFILE` | wc -l)" -gt 1 ]; then
return 1 #false
fi
fi
echo $$ >"$PIDFILE"
return 0 #true
}
freelock()
{
rm "$PIDFILE"
}
WDIR=`dirname $0`
pushd $WDIR >/dev/null
#m_info "Workingdir $WDIR"
if ! getlock; then
m_info "pid `cat $PIDFILE` still running"
exit 3
fi
if [ -e stop -o -e stop.txt ]; then
m_info "stopped"
exit 2
fi
m_ok "start import"
echo $$ >"$PIDFILE"
/bin/cp state.txt last.state.txt
m_ok "downloading diff"
if ! $OSMOSIS --read-replication-interval --simplify-change --write-xml-change "$CURRENT" 1>&2 2> "$OSMOSISLOG"; then
m_error "osmosis error"
fi
NODES=`grep '<node' < "$CURRENT" |wc -l`
WAYS=`grep '<way' < "$CURRENT" |wc -l`
RELS=`grep '<rel' < "$CURRENT" |wc -l`
m_info "expecting Node("$((NODES / 1000))"k) Way("$((WAYS / 1000))"k) Relation("$((RELS / 1000))"k)"
m_ok "importing diff"
if ! $OSM2PGSQL --append --slim --cache 3000 --merc --prefix $PREFIX --style $STYLE --host $HOST --database $DB --username $USER --hstore --verbose "$CURRENT" 1>&2 2> "$PSQLLOG"; then
m_error "osm2pgsql error"
fi
m_ok "import done"
freelock
if [ $EXPIRE -gt 0 ]; then
m_ok "expiring tiles"
if ! sudo -u tirex tile_expiry/do-expire.rb "$CURRENT" 2>&1 > "$EXPIRYLOG"; then
m_error "tile_expiry error"
fi
m_ok "expire done"
fi
/bin/rm -f "$CURRENT"
if [ `wc -l < "$RUNLOG"` -gt 1000 ]; then
m_ok "truncating runlog"
tail -n500 "$RUNLOG" > "$RUNLOG".tmp
mv "$RUNLOG".tmp "$RUNLOG"
fi
popd >/dev/null
I would be very thankful for any help or hint, that helps me solve this matter.
Best regards,
Maroder