#!/usr/bin/env bash
set -xeuo pipefail
find . -maxdepth 2 -mindepth 1 -type d | grep -e '\/.*\/.*' | cut -d\. -f2 | cut -d\/ -f2- | tee -a .rsyncignore
cat .rsyncignore | sort | uniq | tee .rsyncignore.new
mv -v .rsyncignore.new .rsyncignore
ssh -NCL 9969:localhost:22 remote.host &
sleep 2
rsync --exclude-from=.rsyncignore -Pave 'ssh -p 9969' "localhost:/mnt/e/*" .