@@ 19,50 19,44 @@ fi
export BORG_REMOTE_PATH="borg1"
export BORG_REPO="zh1117@zh1117.rsync.net:""$(hostname)"
-export BORG_PASSCOMMAND="cat ""$HOME""/.borg-passphrase"
-
-readonly paths=(
- "/home/rycwo"
-)
-readonly exclude_paths=(
- "/home/rycwo/.borg-passphrase"
- "/home/rycwo/.cache"
- "/home/rycwo/.mozilla"
- "/home/rycwo/.secret"
- "/home/rycwo/.vagrant.d"
- "/home/rycwo/.virtualbox"
- "/home/rycwo/go")
-exclude_file="$(mktemp)"
+export BORG_PASSCOMMAND="cat ""$HOME""/.borg_passphrase"
exit_() {
- status="$?"
-
- # Reset the trap for EXIT so that we don't enter an exit loop
- trap - EXIT
-
- rm -f "$exclude_file"
- exit "$status"
+ echo "$(date)"" Backup interrupted" >&2
+ exit 2
}
-
-trap exit_ EXIT INT TERM QUIT
+trap exit_ INT TERM
# Run borg init if the repo doesn't exist yet
borg list > /dev/null 2>&1 || {
borg init --encryption "repokey"
}
-for path in "${exclude_paths[@]}"; do
- echo "$path" >> "$exclude_file"
-done
-
-# --stats is a nice option if just running as a script
-borg create \
- --verbose \
- --filter AME \
- --list \
- --progress \
- --compression "lzma" \
- --exclude-caches \
- --exclude-from "$exclude_file" \
- "::{hostname}-{now}" \
- "${paths[@]}"
+borg create \
+ --verbose \
+ --filter AME \
+ --list \
+ --show-rc \
+ --stats \
+ --progress \
+ --compression "lzma" \
+ --exclude-caches \
+ --exclude "home/*/.cache/*" \
+ --exclude "var/tmp/*" \
+ "::{hostname}-{now}" \
+ /etc \
+ /home \
+ /root \
+ /var
+
+# Keep 7 end of day, 4 additional end of week archives,
+# and an end of month archive for every month
+borg prune \
+ --list \
+ --prefix "{hostname}-" \
+ --show-rc \
+ --keep-daily 7 \
+ --keep-weekly 4 \
+ --keep-monthly -1
+
+borg compact