From 87e433dd2ea98a0bcbd9a767882af8fa363ef6e3 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Mon, 30 Sep 2019 15:29:28 +0200 Subject: [PATCH] Optimized import and export tool --- scripts/decrypt-data.sh | 1 + scripts/encrypt-data.sh | 1 + scripts/export-data-to-system.sh | 2 ++ scripts/import-data-from-system.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/scripts/decrypt-data.sh b/scripts/decrypt-data.sh index e69de29..a9bf588 100644 --- a/scripts/decrypt-data.sh +++ b/scripts/decrypt-data.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/scripts/encrypt-data.sh b/scripts/encrypt-data.sh index e69de29..a9bf588 100644 --- a/scripts/encrypt-data.sh +++ b/scripts/encrypt-data.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/scripts/export-data-to-system.sh b/scripts/export-data-to-system.sh index e69de29..d27630b 100644 --- a/scripts/export-data-to-system.sh +++ b/scripts/export-data-to-system.sh @@ -0,0 +1,2 @@ +#!/bin/bash +bash ./import-data-from-system.sh reverse diff --git a/scripts/import-data-from-system.sh b/scripts/import-data-from-system.sh index e69de29..89f048a 100644 --- a/scripts/import-data-from-system.sh +++ b/scripts/import-data-from-system.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# 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 +DATA_FOLDER="./data"; +BACKUP_LIST=("$HOME/.gitconfig"); +for system_item_path in "${BACKUP_LIST[@]}"; +do + data_item_path="$DATA_FOLDER$BACKUP_LIST" + if [ "$1" = "reverse" ] + then + destination="$system_item_path" + source="$data_item_path" + else + source="$system_item_path" + destination="$data_item_path" + fi + echo "Data will be copied from $source to $destination..." + if [ -f "$destination" ] + then + echo "The destination file allready exists!"; + echo "Difference:" + diff $destination $source + fi + destination_dir=$(dirname $destination) + mkdir -p "$destination_dir" + cp -vi "$source" "$destination" +done