dotfiles/scripts/backup.sh

63 lines
1.5 KiB
Bash
Raw Normal View History

2018-06-08 19:51:21 +02:00
#!/bin/bash
set -e
set -x
# backup.sh
pre="/home/fschl"
2019-10-15 22:02:16 +02:00
target="/media/store/"
2019-01-04 18:22:44 +01:00
# target="/media/driveBay/Backups"
2018-06-08 19:51:21 +02:00
folders=( "Documents" #contains Org files
"Downloads"
"projects"
)
2019-01-04 18:22:44 +01:00
folders_sensitive=(
2018-06-08 19:51:21 +02:00
".mozilla"
".thunderbird"
".ssh"
2018-07-07 12:47:17 +02:00
".config/etc-tinc"
2018-06-08 19:51:21 +02:00
)
2019-01-04 18:22:44 +01:00
files=(
2018-06-08 19:51:21 +02:00
".bash_history"
)
main() {
local cmd=$1
if [[ -z "$cmd" ]]; then
echo "Usage: \n std | files | sensitive"
fi
case "$cmd" in
std)
for dir in "${folders[@]}";
do
if [ ! -d "${target}/${dir}" ]; then
echo "creating non-existing dir: ${target}/${dir}"
mkdir -p ${target}/$dir
fi
echo "${pre}/${dir} --> ${target}/${dir}"
2019-01-04 18:22:44 +01:00
rsync --progress -ruv --ignore-existing "${pre}/${dir}" "${target}/"
done
;;
sensitive)
for dir in "${folders_sensitive[@]}";
do
if [ ! -d "${target}/${dir}" ]; then
echo "creating non-existing dir: ${target}/dotdirectories/${dir}"
mkdir -p ${target}/dotdirectories/$dir
fi
echo "${pre}/${dir} --> ${target}/${dir}"
rsync --progress -ruv --ignore-existing "${pre}/${dir}" "${target}/dotdirectories/"
2018-06-08 19:51:21 +02:00
done
;;
esac
}
2022-08-24 21:04:46 +02:00
main "$@" 2>&1 | tee "${pre}/backup_$(date +%Y-%m-%d_%H-%M)_$1.log"