From b14a989a2c95fcad30e544eb559742d2a4649ae8 Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Fri, 8 Jun 2018 19:51:21 +0200 Subject: [PATCH] add rsync-backup script --- backup.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 backup.sh diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..3578ce3 --- /dev/null +++ b/backup.sh @@ -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"