<p>osmith has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ci/+/26624">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">contrib/obs-mirror: stop script on rsync error<br><br>Sync files into a temporary directory first, and only rename the temp<br>dir to the final dir name if rsync succeeds. Otherwise, exit with error.<br><br>Related: SYS#5764<br>Change-Id: Icfefd8e4bae1fd6c73445c7427aaa842c0391b2d<br>---<br>M contrib/obs-mirror/obs-mirror.sh<br>1 file changed, 12 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/24/26624/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/contrib/obs-mirror/obs-mirror.sh b/contrib/obs-mirror/obs-mirror.sh</span><br><span>index 8d25c2d..6ac3484 100755</span><br><span>--- a/contrib/obs-mirror/obs-mirror.sh</span><br><span>+++ b/contrib/obs-mirror/obs-mirror.sh</span><br><span>@@ -22,10 +22,11 @@</span><br><span> RSYNC_ARGS="-av --delete"</span><br><span> RSYNC_ARGS="$RSYNC_ARGS --files-from $SCRIPT_DIR/obs-mirror-include.txt --recursive"</span><br><span> DATE=`date +%Y%m%d-%H%M%S`</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-# create output directory</span><br><span> DIR="$BASE_DIR/$DATE"</span><br><span style="color: hsl(0, 100%, 40%);">-mkdir -p "$DIR"</span><br><span style="color: hsl(120, 100%, 40%);">+TEMP_DIR="$BASE_DIR/.temp"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+rm -rf "$TEMP_DIR"</span><br><span style="color: hsl(120, 100%, 40%);">+mkdir "$TEMP_DIR"</span><br><span> </span><br><span> PREVIOUS="$BASE_DIR/.previous"</span><br><span> if [ -d "$PREVIOUS" ]; then</span><br><span>@@ -33,9 +34,12 @@</span><br><span> fi</span><br><span> </span><br><span> # finally, perform rsync</span><br><span style="color: hsl(0, 100%, 40%);">-# || true: don't stop here if one of the dirs from the include list does not exist</span><br><span style="color: hsl(0, 100%, 40%);">-rsync $RSYNC_ARGS "$REMOTE"/ "$DIR"/ || true</span><br><span style="color: hsl(120, 100%, 40%);">+if rsync $RSYNC_ARGS "$REMOTE"/ "$TEMP_DIR"/; then</span><br><span style="color: hsl(120, 100%, 40%);">+ mv "$TEMP_DIR" "$DIR"</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# update '.previous' for the next run</span><br><span style="color: hsl(0, 100%, 40%);">-rm -f "$PREVIOUS"</span><br><span style="color: hsl(0, 100%, 40%);">-ln -sf "$DATE" "$PREVIOUS"</span><br><span style="color: hsl(120, 100%, 40%);">+ # update '.previous' for the next run</span><br><span style="color: hsl(120, 100%, 40%);">+ rm -f "$PREVIOUS"</span><br><span style="color: hsl(120, 100%, 40%);">+ ln -sf "$DATE" "$PREVIOUS"</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ exit 1</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ci/+/26624">change 26624</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-ci/+/26624"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-ci </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Icfefd8e4bae1fd6c73445c7427aaa842c0391b2d </div>
<div style="display:none"> Gerrit-Change-Number: 26624 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>