add rsync-backup script

This commit is contained in:
Frieder Schlesier 2018-06-08 19:51:21 +02:00
parent e489df9293
commit b14a989a2c
1 changed files with 51 additions and 0 deletions

51
backup.sh Executable file
View File

@ -0,0 +1,51 @@
#!/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"