aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2018-03-30 22:24:13 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2018-03-30 22:24:13 +0200
commitecf8bb4b0cbef589c16ee35693ddda8fb84b23f6 (patch)
tree7c73de8224fe65c98a47faa7608a381e0b75aef4
Initial commit, added a skeleton script but need to decide if I'm using the rsync daemon on the master side
-rw-r--r--README.md4
-rwxr-xr-xbackup37
2 files changed, 41 insertions, 0 deletions
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 <src> <dst>"
+ 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
+
+