aboutsummaryrefslogtreecommitdiffstats
path: root/backup
diff options
context:
space:
mode:
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"