Replaced cp through rsync

This commit is contained in:
Kevin Veen-Birkenbach 2019-11-02 09:43:27 +01:00
parent 37984f157d
commit fff8cd0305

View File

@ -12,6 +12,14 @@ if [ -z "$(mount | grep "$DECRYPTED_PATH")" ]
echo "The decrypted folder $DECRYPTED_PATH is locked. You need to unlock it!" echo "The decrypted folder $DECRYPTED_PATH is locked. You need to unlock it!"
bash "$SCRIPT_PATH/unlock.sh" || exit 1; bash "$SCRIPT_PATH/unlock.sh" || exit 1;
fi fi
if [ "$1" = "reverse" ]
then
MODE="export"
else
MODE="import"
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/" \ declare -a BACKUP_LIST=("$HOME/.ssh/" \
"$HOME/.gitconfig" \ "$HOME/.gitconfig" \
"$HOME/.atom/config.cson" \ "$HOME/.atom/config.cson" \
@ -24,7 +32,7 @@ declare -a BACKUP_LIST=("$HOME/.ssh/" \
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"
if [ "$1" = "reverse" ] if [ "$MODE" = "export" ]
then then
destination="$system_item_path" destination="$system_item_path"
source="$data_item_path" source="$data_item_path"
@ -45,12 +53,13 @@ do
if [ -f "$source" ] if [ -f "$source" ]
then then
echo "Copy data from $source to $destination..." echo "Copy data from $source to $destination..."
cp -vi "$source" "$destination" rsync -uWvabPE --update --times --backup-dir="$CONCRETE_BACKUP_FOLDER" "$source" "$destination"
else else
if [ -d "$source" ] if [ -d "$source" ]
then then
echo "Copy data from directory $source to directory $destination_dir..." mkdir -p "$destination"
cp -vir "$source" "$destination_dir" echo "Copy data from directory $source to directory $destination..."
rsync -uWvabrPE --update --times --delete --backup-dir="$CONCRETE_BACKUP_FOLDER" "$source" "$destination"
else else
echo "$source doesn't exist. Copying data is not possible." echo "$source doesn't exist. Copying data is not possible."
fi fi