added bin and wrote backup script, restore isnt finished

This commit is contained in:
2022-01-14 14:19:09 -05:00
parent e15a76ec40
commit d6c388bfb5
15 changed files with 378 additions and 0 deletions

35
restore Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
declare -A to_copy to_rsync
repo="$(pwd)"
# files to copy
to_copy["${HOME}/.bashrc"]='shell/bashrc'
# directories to copy
to_rsync["${HOME}/.config/aliases"]='aliases'
# directories to copy
to_rsync["${HOME}/bin"]='bin'
for dst in "${to_copy[@]}"; do
src="${to_copy[$dst]}"
dir="$(dirname "$src")"
file="$(basename "$src")"
if [[ ! -d "${dir}" ]]; then
mkdir -p "${dir}"
fi
(cd "$dir" && rsync -a "$file" "${dir}"
if [[ $? != 0 ]]; then
printf 'Copying "%s" to "%s" had an error.\n' "$src" "$dst" >&2
fi
done
for dst in "${to_rsync[@]}"; do
src="${to_rsync[$dst]}"
if [[ ! -d "$dst" ]]; then
printf '"%s" does not exist. Can not copy.\n' "$src" >&2
else
(cd "$src" && rsync -a * "${repo}/${dst}/")
fi
done