aboutsummaryrefslogtreecommitdiffstats
path: root/backup
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2018-04-04 20:50:56 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2018-04-04 20:50:56 +0200
commit3ee260ee67ee6e17f583c9cc0ac8f7e37c1ae190 (patch)
tree910a7e171c7d67035d73a8cfaed0660be55041bf /backup
parentecf8bb4b0cbef589c16ee35693ddda8fb84b23f6 (diff)
Made backup script more generic, added specific script for stromboli
Diffstat (limited to 'backup')
-rwxr-xr-xbackup36
1 files changed, 19 insertions, 17 deletions
diff --git a/backup b/backup
index 609c282..c9abda8 100755
--- a/backup
+++ b/backup
@@ -1,37 +1,39 @@
#!/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.
+# rsyncs data from one directory to another. By default all subdirectories of the src directory are copied to the dst directory. Nothing happens unless both arguments are valid directories.
-RSYNC_OPTS='-aP \
+LOG_DIR="$HOME/rsync_logs"
+LOG_FILE="$LOG_DIR/$(date --iso-8601).log"
+
+RSYNC_OPTS="-aP \
--no-owner \
--delete-during \
- --exclude="lost+found"'
+ --exclude='lost+found'
+ --log-file='$LOG_FILE'"
if [ $# -lt 2 ]; then
echo "Usage: backup <src> <dst>"
exit 1
fi
-if [ ! -e $1 ]; then
- echo "$1 does not exist"
+if [ ! -d "$1" ]; then
+ echo "$1 does not exist or is not a directory"
exit 1
fi
-if [ ! -e $2 ]; then
- echo "$2 does not exist"
+if [ ! -d "$2" ]; then
+ echo "$2 does not exist or is not a directory"
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
+if [ ! -d "$LOG_DIR" ]; then
+ echo "Log directory does not exist, creating"
+ mkdir -p "$LOG_DIR"
-lsblk | awk '{ print $7 }' | grep -Fx "$2" > /dev/null
-if [ $? -ne 0 ]; then
- echo "$2 is not a mount point"
- exit 1
+ if [ $? -ne 0 ]; then
+ echo "Failed to create log directory, exiting"
+ exit 1
+ fi
fi
-
+rsync $RSYNC_OPTS "${1%/}/*" "$2"