Files
scripts/linux/tasks/rsync local folders.sh
2023-08-30 23:40:59 +00:00

28 lines
770 B
Bash

#!/bin/bash
source_dir="/mnt/storage/nextcloud/popov/files/PORTABLE/"
destination_dir="/mnt/nas4T/DOBY/Portable/"
# Check if the source directory exists
if [ ! -d "$source_dir" ]; then
echo "Source directory not found: $source_dir"
exit 1
fi
# Check if the destination directory exists
if [ ! -d "$destination_dir" ]; then
echo "Destination directory not found: $destination_dir"
exit 1
fi
# Loop through the subdirectories in the source directory
for subdir in "$source_dir"/*; do
if [ -d "$subdir" ]; then
subfolder=$(basename "$subdir")
echo "Syncing $subfolder..."
rsync -ah --info=progress2 --relative --rsync-path="mkdir -p '$destination_dir' && rsync" "$source_dir$subfolder/" "$destination_dir"
fi
done
echo "All subfolders synced."