rsync

Tom Roche Tom_Roche at pobox.com
Sun Feb 7 12:54:37 MST 2016


Michael @ http://lists.phxlinux.org/lurker/message/20160207.022735.736d654f.en.html
> I ran this command:

> rsync -aWuq --delete-before /home/bmike1/Pictures /home/bmike1/Music /media/bmike1/Lexar32G

> and I do not know if it worked.

For a good first approximation, compare the source and target directories/folders with, e.g., `du -s` and `find | wc -l`. That's also why I would not copy multiple source dirs into one target dir: it complicates that sort of check. Instead drive `rsync` with something like (in bash)

RSYNC_OPTS='-aWuq --delete-before' # forces me to think about it
TARGET_ROOT='/media/bmike1/Lexar32G'
for SOURCE_DIR in \
  '/home/bmike1/Music' \
  '/home/bmike1/Pictures' \
; do
  TARGET_DIR="${TARGET_ROOT}/$(basename ${SOURCE_DIR})"
  for CMD in \
    'date' \
    "du -s ${SOURCE_DIR}" \
    "find ${SOURCE_DIR} | wcl" \
    "mkdir -p ${TARGET_DIR}" \
    "rsync ${RSYNC_OPTS} ${SOURCE_DIR}/ ${TARGET_DIR}/" \
    "du -s ${TARGET_DIR}" \
    "find ${TARGET_DIR} | wcl" \
    'date' \
  ; do
    echo -e "${CMD}"
#    eval "${CMD}"
  done
  echo # newline
done

Run that with the `eval` commented out first, just to show you what the commandlines are gonna be: if they look OK, uncomment the `eval` to actually do something.

HTH, Tom Roche <Tom_Roche at pobox.com>


More information about the PLUG-discuss mailing list