aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-05-12 00:33:26 -0300
committerEuAndreh <eu@euandre.org>2022-05-12 00:33:28 -0300
commit3ffd4cdbf86ce1c70eeacf1404ca81df2fa6399c (patch)
tree39f317fa1aa860780f6bbca297cfef7808f29aa2
parent~/.local/bin/email: Add working script! (diff)
downloaddotfiles-3ffd4cdbf86ce1c70eeacf1404ca81df2fa6399c.tar.gz
dotfiles-3ffd4cdbf86ce1c70eeacf1404ca81df2fa6399c.tar.xz
~/.local/bin/backup: Clean up script
- remove "borg check" and "borg prune" steps; - stop sourcing ~/.bash_profile; - ignore return code 1 from "borg create" command, as detailed in the documentation [0]: > warning (operation reached its normal end, but there > were warnings – you should check the log, logged as WARNING) [0]: https://borgbackup.readthedocs.io/en/stable/usage/general.html
-rwxr-xr-x.local/bin/backup38
1 files changed, 19 insertions, 19 deletions
diff --git a/.local/bin/backup b/.local/bin/backup
index d77425c8..cab37dc5 100755
--- a/.local/bin/backup
+++ b/.local/bin/backup
@@ -1,5 +1,4 @@
#!/bin/sh
-. ~/.bash_profile
set -eu
usage() {
@@ -99,8 +98,6 @@ assert_arg() {
ARCHIVE_TAG="${1:-}"
assert_arg "$ARCHIVE_TAG" 'ARCHIVE_TAG'
-set -x
-
finish() {
STATUS=$?
@@ -108,21 +105,24 @@ finish() {
}
trap finish EXIT
-borg create \
- $VERBOSE_FLAGS \
- --comment "$COMMENT" \
- --exclude ~/.cache \
- --stats \
- --compression lzma,9 \
- "::{hostname}-{now}-$ARCHIVE_TAG" \
- ~/ ||:
+run() {
+ borg create \
+ $VERBOSE_FLAGS \
+ --comment "$COMMENT" \
+ --exclude ~/.cache/ \
+ --exclude ~/Downloads/ \
+ --stats \
+ --compression lzma,9 \
+ "::{hostname}-{now}-$ARCHIVE_TAG" \
+ ~/
+ STATUS=$?
-borg check \
- --verbose
+ if [ "$STATUS" = 0 ] || [ "$STATUS" = 1 ]; then
+ echo 'WARNING, but no ERROR.' >&2
+ return 0
+ else
+ return "$STATUS"
+ fi
+}
-borg prune \
- --verbose \
- --list \
- --keep-within=6m \
- --keep-weekly=52 \
- --keep-monthly=24
+run || exit $?