From eb47f44a29765408d4aa8845bca3a114f73c3378 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Tue, 3 Dec 2019 14:22:10 +0100 Subject: [PATCH] Optimized backup folders --- scripts/base.sh | 9 +++++++++ scripts/import-data-from-system.sh | 17 ++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/base.sh b/scripts/base.sh index ed293ce..aace22a 100644 --- a/scripts/base.sh +++ b/scripts/base.sh @@ -12,3 +12,12 @@ DATA_PATH="$DECRYPTED_PATH/data"; BACKUP_PATH="$DECRYPTED_PATH/backup"; TEMPLATE_PATH="$REPOSITORY_PATH/templates"; LOCAL_REPOSITORIES_PATH="$HOME/Documents/repositories"; +declare -a BACKUP_LIST=("$HOME/.ssh/" \ + "$HOME/.gitconfig" \ + "$HOME/.atom/config.cson" \ + "$HOME/Documents/certificates/" \ + "$HOME/Documents/recovery_codes/" \ + "$HOME/Documents/identity/" \ + "$HOME/Documents/passwords/" \ + "$HOME/.local/share/rhythmbox/rhythmdb.xml" \ + "$HOME/.config/keepassxc/keepassxc.ini"); diff --git a/scripts/import-data-from-system.sh b/scripts/import-data-from-system.sh index 678863d..4a79439 100644 --- a/scripts/import-data-from-system.sh +++ b/scripts/import-data-from-system.sh @@ -20,15 +20,6 @@ if [ "$1" = "reverse" ] fi CONCRETE_BACKUP_FOLDER="$BACKUP_PATH/$MODE/$(date '+%Y%m%d%H%M%S')" mkdir -p "$CONCRETE_BACKUP_FOLDER" -declare -a BACKUP_LIST=("$HOME/.ssh/" \ - "$HOME/.gitconfig" \ - "$HOME/.atom/config.cson" \ - "$HOME/Documents/certificates/" \ - "$HOME/Documents/recovery_codes/" \ - "$HOME/Documents/identity/" \ - "$HOME/Documents/passwords/" \ - "$HOME/.local/share/rhythmbox/rhythmdb.xml" \ - "$HOME/.config/keepassxc/keepassxc.ini"); for system_item_path in "${BACKUP_LIST[@]}"; do data_item_path="$DATA_PATH$system_item_path" @@ -52,14 +43,18 @@ do mkdir -p "$destination_dir" if [ -f "$source" ] then + backup_dir=$(dirname "$CONCRETE_BACKUP_FOLDER/$system_item_path"); + mkdir -p "$backup_dir" echo "Copy data from $source to $destination..." - rsync -abcEPuvW --backup-dir="$CONCRETE_BACKUP_FOLDER" "$source" "$destination" + rsync -abcEPuvW --backup-dir="$backup_dir" "$source" "$destination" else if [ -d "$source" ] then mkdir -p "$destination" + backup_dir="$CONCRETE_BACKUP_FOLDER/$system_item_path"; + mkdir -p "$backup_dir" echo "Copy data from directory $source to directory $destination..." - rsync -abcEPuvW --delete --backup-dir="$CONCRETE_BACKUP_FOLDER" "$source" "$destination" + rsync -abcEPuvW --delete --backup-dir="$backup_dir" "$source" "$destination" else echo "$source doesn't exist. Copying data is not possible." fi