#!/bin/bash set -e set -x # backup.sh pre="/home/fschl" target="/media/driveBay/Backups" folders=( "Documents" #contains Org files "Downloads" "projects" ) folders_sensitive=( ".gnupg" ".mozilla" ".thunderbird" ".ssh" ) files=( ".android" ".gradle" ".bash_history" ".Clion2016.3" ".revive.el" ) main() { local cmd=$1 if [[ -z "$cmd" ]]; then echo "Usage: \n std | files | sensitive" fi case "$cmd" in std) for dir in "${folders[@]}"; do if [ ! -d "${target}/${dir}" ]; then echo "creating non-existing dir: ${target}/${dir}" mkdir -p ${target}/$dir fi echo "${pre}/${dir} --> ${target}/${dir}" rsync --progress -ruv "${pre}/${dir}" "${target}/" done ;; esac } main "$@" 2>&1 | tee "${pre}/backup_$(date +%Y-%M-%d_%H-%M)_$1.log"