From b97f0a5cf4db22dfcb5c45a35b06dc4573f9ffb1 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Thu, 29 Feb 2024 01:38:01 -0800 Subject: [PATCH] Update copy.sh to use rsync and a tmp file in the /tmp/ directory --- homelab/barbarian/copy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homelab/barbarian/copy.sh b/homelab/barbarian/copy.sh index 8fdea6b9..ddf47ea4 100644 --- a/homelab/barbarian/copy.sh +++ b/homelab/barbarian/copy.sh @@ -1,8 +1,8 @@ #!/bin/sh FROM_DIR=$1 # trailing slash -TO_DIR=$2 # no trailing slash +TO_DIR=$2 # trailing slash -cp -rv $FROM_DIR $TO_DIR > copy.tmp +rsync -avhW $FROM_DIR $TO_DIR > /tmp/copy.tmp # If filesize is less than 23 million bytes (21.93 MiB) # Gives generous headroom for Gmail max attachment size @@ -28,7 +28,7 @@ if [ $(ls -la copy.tmp | awk '{print $5}') -le 23000000 ]; then echo "--d29a0c638b540b23e9a29a3a9aebc900aeeb6a82--" ) | sendmail root - rm copy.tmp + rm /tmp/copy.tmp else echo "Filesize too large to attach. See log file for details." | mail -s "Copy $FROM_DIR to $TO_DIR operation complete." root mv copy.tmp copy_$(date +"%y-%m-%d").log