Optimized backup folders

This commit is contained in:
Kevin Veen-Birkenbach 2019-12-03 14:22:10 +01:00
parent 022269c189
commit eb47f44a29
2 changed files with 15 additions and 11 deletions

View File

@ -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");

View File

@ -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