Add excludes

This commit is contained in:
Austen Adler 2019-10-26 14:37:11 -04:00
parent 58aa9b95e6
commit 0efc9a416c
3 changed files with 36 additions and 18 deletions

View File

@ -71,8 +71,8 @@ location:
# Read exclude patterns from one or more separate named files, one pattern per
# line. See the output of "borg help patterns" for more details.
#exclude_from:
# - /etc/borgmatic/excludes
exclude_from:
- EXCLUDE_FROM_PLACEHOLDER
# Exclude directories that contain a CACHEDIR.TAG file. See
# http://www.brynosaurus.com/cachedir/spec.html for details. Defaults to false.

7
excludes Normal file
View File

@ -0,0 +1,7 @@
/storage/emulated/0/*/.thumbnails
/storage/emulated/0/Android
/storage/emulated/0/Download/*.bin
/storage/emulated/0/Download/*.exe
/storage/emulated/0/Download/Images
/storage/emulated/0/Movies
/storage/emulated/0/syncthing

43
init.sh
View File

@ -12,7 +12,11 @@ die() {
exit 1
}
install_requirements() {
apt-get update
LAST_UPDATE="$(stat -c %Y /data/data/com.termux/files/usr/var/cache/apt/pkgcache.bin)"
NOW="$(date +%s)"
if ((NOW - LAST_UPDATE > 60 * 60 * 24)); then
apt-get update
fi
apt-get upgrade -y
apt-get install -y python screen wget
@ -35,14 +39,14 @@ install_debs() {
replace () {
FILE="$1"
PLACEHOLDER="${2}_PLACEHOLDER"
PROMT="$3"
DEFAULT="$4"
printf "$PROMT [$DEFAULT] > "
read -r RESP
if [[ -z "$RESP" ]]; then
VALUE="$DEFAULT"
else
VALUE="$RESP"
VALUE="$3"
if (( $# == 4 )); then
PROMT="$4"
printf "%s" "$PROMT [$VALUE] > "
read -r
if [[ -n "$REPLY" ]]; then
VALUE="$REPLY"
fi
fi
# Do the replacement
@ -51,20 +55,29 @@ replace () {
install_templates() {
echo "Installling templates"
BORGMATIC_CONFIG_FILE="$HOME/.config/borgmatic/config.yaml"
BORGMATIC_EXCLUDES_FILE="$HOME/.config/borgmatic/excludes"
if [[ "$1" = "-f" ]] || [[ ! -e "$BORGMATIC_CONFIG_FILE" ]]; then
mkdir -p "$HOME/.config/borgmatic"
cp "$SCRIPT_DIR/config.yaml" "$BORGMATIC_CONFIG_FILE"
set +x
replace "$BORGMATIC_CONFIG_FILE" REPO "What is your repository?" "user@files:$(hostname)"
replace "$BORGMATIC_CONFIG_FILE" CROSS_FILESYSTEM "Cross filesystem?" "true"
replace "$BORGMATIC_CONFIG_FILE" REMOTE_PATH "Remote borg command?" "borg1"
replace "$BORGMATIC_CONFIG_FILE" PASSWORD "Encryption password?" "$(tr -dc "+|~=[];:\-/.,<>?'#@!$%^&*(){}_A-Z-a-z-0-9" < /dev/urandom | head -c32)"
set -x
replace "$BORGMATIC_CONFIG_FILE" REPO "user@files:$(hostname)" "What is your repository?"
replace "$BORGMATIC_CONFIG_FILE" CROSS_FILESYSTEM "true" "Cross filesystem?"
replace "$BORGMATIC_CONFIG_FILE" REMOTE_PATH "borg1" "Remote borg command?"
replace "$BORGMATIC_CONFIG_FILE" PASSWORD "$(tr -dc "+|~=[];:\-/.,<>?'#@!$%^&*(){}_A-Z-a-z-0-9" < /dev/urandom | head -c32)" "Encryption password?"
replace "$BORGMATIC_CONFIG_FILE" EXCLUDE_FROM "$BORGMATIC_EXCLUDES_FILE"
set -x
echo "Config file differences:"
diff -Nu "$SCRIPT_DIR/config.yaml" "$BORGMATIC_CONFIG_FILE" || :
fi
if [[ "$1" = "-f" ]] || [[ ! -e "$BORGMATIC_EXCLUDES_FILE" ]]; then
mkdir -p "$HOME/.config/borgmatic"
cp "$SCRIPT_DIR/excludes" "$BORGMATIC_EXCLUDES_FILE"
fi
}
install_complete() {
@ -84,8 +97,6 @@ install_complete() {
cd "/data/data/com.termux/files/usr/tmp/tmp.k5RE3ly9Hm"
# cd "$(mktemp -d)"
install_requirements
# get_debs
# install_debs
install_templates "$1"
install_complete
}