#!/usr/bin/env bash # TODO LEGACY: USE BTRBK ask_ok() { read -r -p "$* [y/N]: " response response=${response,,} [[ ! "$response" =~ ^(yes|y)$ ]] && return 1 return 0 } declare -a include_dirs=( "$HOME/music" "$HOME/documents" "$HOME/downloads" "$HOME/pictures" "$HOME/ebooks" "$HOME/devices" "$HOME"/.* ) declare -a exclude_dirs=( "$HOME/.**" "$HOME/..**" ) declare destination="/run/media/bryan/4tb-external/$HOSTNAME" declare rsync_cmd="rsync -aAXL --info=progress2 --delete" for i in "${include_dirs[@]}"; do rsync_cmd+=" --include $i**" done for i in "${exclude_dirs[@]}"; do rsync_cmd+=" --exclude $i" done echo "Command to run: $rsync_cmd $destination" ask_ok "Continue?" || exit 1 [[ ! -d "$destination" ]] && mkdir -p "$destination" eval "$rsync_cmd $destination"