aboutsummaryrefslogtreecommitdiffstats
path: root/backup
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 /backup
Initial commit, added a skeleton script but need to decide if I'm using the rsync daemon on the master side
Diffstat (limited to 'backup')
-rwxr-xr-xbackup37
1 files changed, 37 insertions, 0 deletions
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
+
+