Skip to content

Commit

Permalink
Copy hourly and daily replication diffs to S3
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Sep 24, 2023
1 parent 29d6902 commit f6fef27
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
16 changes: 16 additions & 0 deletions cookbooks/planet/files/default/replication-bin/replicate-day
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day

. /store/planet/replication/day/state.txt

sequencePart1=$(($sequenceNumber / 1000000 % 1000))
sequencePart2=$(($sequenceNumber / 1000 % 1000))
sequencePart3=$(($sequenceNumber % 1000))
diffPath=$(printf "%03d/%03d/%03d" $sequencePart1 $sequencePart2 $sequencePart3)

/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/day/${diffPath}.osc.gz" "s3://osm-planet-eu-central-1/planet/replication/day/${diffPath}.osc.gz"
/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/day/${diffPath}.state.txt" "s3://osm-planet-eu-central-1/planet/replication/day/${diffPath}.state.txt"
/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/day/state.txt" "s3://osm-planet-eu-central-1/planet/replication/day/state.txt"
16 changes: 16 additions & 0 deletions cookbooks/planet/files/default/replication-bin/replicate-hour
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour

. /store/planet/replication/hour/state.txt

sequencePart1=$(($sequenceNumber / 1000000 % 1000))
sequencePart2=$(($sequenceNumber / 1000 % 1000))
sequencePart3=$(($sequenceNumber % 1000))
diffPath=$(printf "%03d/%03d/%03d" $sequencePart1 $sequencePart2 $sequencePart3)

/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/hour/${diffPath}.osc.gz" "s3://osm-planet-eu-central-1/planet/replication/hour/${diffPath}.osc.gz"
/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/hour/${diffPath}.state.txt" "s3://osm-planet-eu-central-1/planet/replication/hour/${diffPath}.state.txt"
/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/hour/state.txt" "s3://osm-planet-eu-central-1/planet/replication/hour/state.txt"
8 changes: 6 additions & 2 deletions cookbooks/planet/recipes/replication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,12 @@
systemd_service "replication-hourly" do
description "Hourly replication"
user "planet"
exec_start "/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour"
exec_start "/usr/local/bin/replicate-hour"
environment "LD_PRELOAD" => "/opt/flush/flush.so"
sandbox :enable_network => true
memory_deny_write_execute false
protect_home "tmpfs"
bind_paths "/home/planet"
read_write_paths [
"/store/planet/replication/hour",
"/var/lib/replication/hour"
Expand Down Expand Up @@ -358,10 +360,12 @@
systemd_service "replication-daily" do
description "Daily replication"
user "planet"
exec_start "/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day"
exec_start "/usr/local/bin/replicate-day"
environment "LD_PRELOAD" => "/opt/flush/flush.so"
sandbox :enable_network => true
memory_deny_write_execute false
protect_home "tmpfs"
bind_paths "/home/planet"
read_write_paths [
"/store/planet/replication/day",
"/var/lib/replication/day"
Expand Down

0 comments on commit f6fef27

Please sign in to comment.