#!/bin/bash
# 
# rsync-options: rltD
# recursive, links, times, devices, specials
# ! not: permissions, group, owner; not needed by saving NTFS-files
#
# 090918

# Aktuelles Datum für Dateinamen
DATUM=`/bin/date '+%Y%m%d-%H%M'`
echo Datum: $DATUM
newest_dest_dir_name=`find /media/archiv/sda7 -maxdepth 1 -type d -print | \
      grep  -e "[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]" | \
      sed 's/.*\/\(.*\)$/\1/g' | sort -r | head -n 1` 
echo "newest Dir name: $newest_dest_dir_name"
link_path="/media/archiv/sda7/$newest_dest_dir_name/"
excl_path="./excludes.sda7"
srcs="./sources.sda7"
src_path="/media/W3-TMP"
dest_path="/media/archiv/sda7"
log_path="$dest_path/$DATUM.log"
dest_path="$dest_path/$DATUM"




[ -d $dest_path ] || mkdir $dest_path
### rsync opts --link-dest=<path> --exclude <path> <src-path> <dest-path>
# echo "rsync -rltDv --recursive --progress --link-dest=$link_path --exclude-from=$excl_path --log-file=$log_path --files-from=$srcs $src_path $dest_path" # ok
nice -n 15 rsync -rltDv --recursive --progress --link-dest=$link_path --exclude-from=$excl_path --log-file=$log_path --files-from=$srcs $src_path $dest_path

