2018-06-08 19:51:21 +02:00
|
|
|
#!/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"
|
2018-07-07 12:47:17 +02:00
|
|
|
".config/etc-tinc"
|
2018-06-08 19:51:21 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
files=( ".android"
|
|
|
|
".gradle"
|
|
|
|
".bash_history"
|
|
|
|
".Clion2016.3"
|
|
|
|
)
|
|
|
|
|
|
|
|
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"
|