From ecf8bb4b0cbef589c16ee35693ddda8fb84b23f6 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Fri, 30 Mar 2018 22:24:13 +0200 Subject: Initial commit, added a skeleton script but need to decide if I'm using the rsync daemon on the master side --- README.md | 4 ++++ backup | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 README.md create mode 100755 backup diff --git a/README.md b/README.md new file mode 100644 index 0000000..5622605 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# backup +A wrapper that synchronises the contents of two directories using rsync. Intended for use in stromboli to backup the files from vesuvio. + +This script also does some checks to ensure that both data and backup directories are mounted correctly before attempting to copy. diff --git a/backup b/backup new file mode 100755 index 0000000..609c282 --- /dev/null +++ b/backup @@ -0,0 +1,37 @@ +#!/usr/bin/zsh + +# rsyncs data from one mount point to another. By default all subdirectories of the src mount point are copied to the dst mount point. Nothing happens unless both arguments are valid mount points. + +RSYNC_OPTS='-aP \ + --no-owner \ + --delete-during \ + --exclude="lost+found"' + +if [ $# -lt 2 ]; then + echo "Usage: backup " + exit 1 +fi + +if [ ! -e $1 ]; then + echo "$1 does not exist" + exit 1 +fi + +if [ ! -e $2 ]; then + echo "$2 does not exist" + exit 1 +fi + +lsblk | awk '{ print $7 }' | grep -Fx "$1" > /dev/null +if [ $? -ne 0 ]; then + echo "$1 is not a mount point" + exit 1 +fi + +lsblk | awk '{ print $7 }' | grep -Fx "$2" > /dev/null +if [ $? -ne 0 ]; then + echo "$2 is not a mount point" + exit 1 +fi + + -- cgit v1.2.3