NEW: rsync script with logs
This commit is contained in:
parent
a7cb56a514
commit
4d0c692bf0
29
sh/rsync-job.sh
Normal file
29
sh/rsync-job.sh
Normal file
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user