cmc-sales/archive/scripts/sync_docs.sh

34 lines
852 B
Bash
Raw Permalink Normal View History

#!/bin/bash
set -e
# Default target directory for docs
TARGET_DIR="/mnt/cmc-docs"
# Parse optional target dir
for arg in "$@"; do
if [[ "$arg" == "-target" ]]; then
NEXT_IS_TARGET=1
continue
fi
if [[ $NEXT_IS_TARGET == 1 ]]; then
TARGET_DIR="$arg"
NEXT_IS_TARGET=0
fi
done
PDF_SRC="/mnt/vault/pdf"
ATTACH_SRC="/mnt/vault/attachments_files"
PDF_DEST="$TARGET_DIR/pdf"
ATTACH_DEST="$TARGET_DIR/attachments_files"
mkdir -p "$PDF_DEST" "$ATTACH_DEST"
# Sync PDF files from remote host
rsync -avz -e "ssh -i ~/.ssh/cmc-old" --progress cmc@sales.cmctechnologies.com.au:"$PDF_SRC/" "$PDF_DEST/"
# Sync attachment files from remote host
rsync -avz -e "ssh -i ~/.ssh/cmc-old" --progress cmc@sales.cmctechnologies.com.au:"$ATTACH_SRC/" "$ATTACH_DEST/"
echo "Sync complete. Files are in $TARGET_DIR (pdf/ and attachments_files/)"