diff --git a/sh/rsync-job.sh b/sh/rsync-job.sh new file mode 100644 index 0000000..2c4133a --- /dev/null +++ b/sh/rsync-job.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +function log() { + echo "$(date -u): /opt/rxt/nfs-rsync.sh - $@" >> /var/log/nfs-rsync-job.log +} + +# Empty previous log +truncate -s0 /var/log/nfs-rsync.log + +# First check that /content is mounted +if grep -q /content /proc/mounts ; then + log target mount exist, continuing. +else + log FAILED. target mount is missing. + exit 1 +fi + +# Check if rsync is already running +if pgrep -f 'rsync.*/var/log/nfs-rsync.log'; then + log WARNING. another instance of /opt/rxt/nfs-rsync.sh is already running. skipping this run. + exit 1 +fi + +if rsync -axz --delete-delay --ignore-missing-args --stats --log-file=/var/log/nfs-rsync.log 192.168.102.62:/san/nfs-fs/ /content/; then + log OK. rsync completed successfully +else + log FAILED. rsync did not complete with exit code $?. please refer to /var/log/nfs-rsync.log for additional details. +fi +