From 87101e8349d9fc1e9b288000df2cb6ced71d975d Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Fri, 4 Jan 2019 18:22:44 +0100 Subject: [PATCH] improve backup script --- scripts/backup.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/backup.sh b/scripts/backup.sh index 4a06fa7..a7edb72 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -5,24 +5,23 @@ set -x # backup.sh pre="/home/fschl" -target="/media/driveBay/Backups" +target="/media/black_Backups/2018-12" +# target="/media/driveBay/Backups" folders=( "Documents" #contains Org files "Downloads" "projects" ) -folders_sensitive=( ".gnupg" +folders_sensitive=( ".mozilla" ".thunderbird" ".ssh" ".config/etc-tinc" ) -files=( ".android" - ".gradle" +files=( ".bash_history" - ".Clion2016.3" ) main() { @@ -41,7 +40,19 @@ main() { mkdir -p ${target}/$dir fi echo "${pre}/${dir} --> ${target}/${dir}" - rsync --progress -ruv "${pre}/${dir}" "${target}/" + rsync --progress -ruv --ignore-existing "${pre}/${dir}" "${target}/" + done + ;; + + sensitive) + for dir in "${folders_sensitive[@]}"; + do + if [ ! -d "${target}/${dir}" ]; then + echo "creating non-existing dir: ${target}/dotdirectories/${dir}" + mkdir -p ${target}/dotdirectories/$dir + fi + echo "${pre}/${dir} --> ${target}/${dir}" + rsync --progress -ruv --ignore-existing "${pre}/${dir}" "${target}/dotdirectories/" done ;;