Adapted scripts to new base frame

This commit is contained in:
Kevin Veen-Birkenbach 2020-05-03 20:16:46 +02:00
parent 9d8dfd33a0
commit 60c9ce8a0f
4 changed files with 20 additions and 21 deletions

View File

@ -2,5 +2,5 @@
# Executes all scripts which are necessary to backup data # Executes all scripts which are necessary to backup data
# @author Kevin Veen-Birkenbach [aka. Frantz] # @author Kevin Veen-Birkenbach [aka. Frantz]
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1) source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
bash "$SCRIPT_PATH/import-data-from-system.sh" bash "$SCRIPT_PATH""client/import-data-from-system.sh"
bash "$SCRIPT_PATH/push-local-repositories.sh" bash "$SCRIPT_PATH""client/push-local-repositories.sh"

View File

@ -3,4 +3,4 @@
# @author Kevin Veen-Birkenbach [aka. Frantz] # @author Kevin Veen-Birkenbach [aka. Frantz]
# shellcheck source=/dev/null # Deactivate SC1090 # shellcheck source=/dev/null # Deactivate SC1090
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1) source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
bash "$SCRIPT_PATH/import-data-from-system.sh" reverse bash "$SCRIPT_PATH""client/import-data-from-system.sh" reverse

View File

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Imports data from the system # Imports data from the system
# @author Kevin Veen-Birkenbach [aka. Frantz]
# @param $1 If the first parameter is "reverse" the data will be exported to the system # @param $1 If the first parameter is "reverse" the data will be exported to the system
# #
# shellcheck source=/dev/null # Deactivate SC1090 # shellcheck source=/dev/null # Deactivate SC1090
@ -9,8 +8,8 @@
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1) source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
if [ -z "$(mount | grep "$DECRYPTED_PATH")" ] if [ -z "$(mount | grep "$DECRYPTED_PATH")" ]
then then
echo "The decrypted folder $DECRYPTED_PATH is locked. You need to unlock it!" info "The decrypted folder $DECRYPTED_PATH is locked. You need to unlock it!" &&
bash "$SCRIPT_PATH/unlock.sh" || exit 1; bash "$SCRIPT_PATH/unlock.sh" || error "Unlocking failed.";
fi fi
if [ "$1" = "reverse" ] if [ "$1" = "reverse" ]
then then
@ -19,7 +18,7 @@ if [ "$1" = "reverse" ]
MODE="import" MODE="import"
fi fi
CONCRETE_BACKUP_FOLDER="$BACKUP_PATH/$MODE/$(date '+%Y%m%d%H%M%S')" CONCRETE_BACKUP_FOLDER="$BACKUP_PATH/$MODE/$(date '+%Y%m%d%H%M%S')"
mkdir -p "$CONCRETE_BACKUP_FOLDER" mkdir -p "$CONCRETE_BACKUP_FOLDER" || error "Failed to create \"$CONCRETE_BACKUP_FOLDER\"."
for system_item_path in "${BACKUP_LIST[@]}"; for system_item_path in "${BACKUP_LIST[@]}";
do do
data_item_path="$DATA_PATH$system_item_path" data_item_path="$DATA_PATH$system_item_path"
@ -27,36 +26,36 @@ do
then then
destination="$system_item_path" destination="$system_item_path"
source="$data_item_path" source="$data_item_path"
echo "Export data from $source to $destination..." info "Export data from $source to $destination..."
else else
source="$system_item_path" source="$system_item_path"
destination="$data_item_path" destination="$data_item_path"
echo "Import data from $source to $destination..." info "Import data from $source to $destination..."
fi fi
if [ -f "$destination" ] if [ -f "$destination" ]
then then
echo "The destination file allready exists!"; info "The destination file allready exists!" &&
echo "Difference:" info "Difference:" &&
diff "$destination" "$source" diff "$destination" "$source"
fi fi
destination_dir=$(dirname "$destination") destination_dir=$(dirname "$destination")
mkdir -p "$destination_dir" mkdir -p "$destination_dir" || error "Failed to create \"$destination_dir\"."
if [ -f "$source" ] if [ -f "$source" ]
then then
backup_dir=$(dirname "$CONCRETE_BACKUP_FOLDER/$system_item_path"); backup_dir=$(dirname "$CONCRETE_BACKUP_FOLDER/$system_item_path");
mkdir -p "$backup_dir" mkdir -p "$backup_dir" || error "Failed to create \"$backup_dir\"."
echo "Copy data from $source to $destination..." info "Copy data from $source to $destination..."
rsync -abcEPuvW --backup-dir="$backup_dir" "$source" "$destination" rsync -abcEPuvW --backup-dir="$backup_dir" "$source" "$destination" || error "Failed."
else else
if [ -d "$source" ] if [ -d "$source" ]
then then
mkdir -p "$destination" mkdir -p "$destination" || error "Failed to create \"$destination\"."
backup_dir="$CONCRETE_BACKUP_FOLDER/$system_item_path"; backup_dir="$CONCRETE_BACKUP_FOLDER/$system_item_path";
mkdir -p "$backup_dir" mkdir -p "$backup_dir" || error "Failed to create \"$backup_dir\"."
echo "Copy data from directory $source to directory $destination..." info "Copy data from directory $source to directory $destination..."
rsync -abcEPuvW --delete --backup-dir="$backup_dir" "$source" "$destination" rsync -abcEPuvW --delete --backup-dir="$backup_dir" "$source" "$destination" || error "Failed."
else else
echo "$source doesn't exist. Copying data is not possible." warning "$source doesn't exist. Copying data is not possible."
fi fi
fi fi
done done