aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rwxr-xr-xbackup36
-rwxr-xr-xstromboli_backup7
3 files changed, 29 insertions, 18 deletions
diff --git a/README.md b/README.md
index 5622605..fa61316 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
# 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.
+This script also does some checks to ensure that both source and destination directories exist, and it logs the output of rsync.
+
+`backup` is a generic backup script. `stromboli_backup` is a wrapper that uses `backup` but has some hardcoded parameters specific to stromboli.
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"
diff --git a/stromboli_backup b/stromboli_backup
new file mode 100755
index 0000000..4263065
--- /dev/null
+++ b/stromboli_backup
@@ -0,0 +1,7 @@
+#!/usr/bin/zsh
+# Backup script for stromboli. This synchronises stromboli's local storage with the NFS data from vesuvio. Since this script mounts and umounts the NFS, it should be configured to be mountable without root on fstab.
+
+mount /home/eddy/data
+/home/eddy/bin/backup /home/eddy/data /home/eddy/backup
+sync
+umount /home/eddy/data