aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-10-28 14:00:34 +0200
committerOscar Najera <hi@oscarnajera.com>2023-10-28 14:00:56 +0200
commit83c920263fe366fc530d1287badfc869767695cf (patch)
tree08f045baf0aa22a13dac37503a5861177cd9f708
parent8056f2d696da9d89b5770bd1ca097bf82aca3bab (diff)
downloaddotfiles-83c920263fe366fc530d1287badfc869767695cf.tar.gz
dotfiles-83c920263fe366fc530d1287badfc869767695cf.tar.bz2
dotfiles-83c920263fe366fc530d1287badfc869767695cf.zip
[fix] local backup script with shellcheck
-rwxr-xr-xbin/backup.sh21
1 files changed, 11 insertions, 10 deletions
diff --git a/bin/backup.sh b/bin/backup.sh
index aa8e6e1..8887095 100755
--- a/bin/backup.sh
+++ b/bin/backup.sh
@@ -1,11 +1,12 @@
#! /bin/bash
+set -e
backup_local() {
# external program to supply the passphrase:
export BORG_PASSCOMMAND="pass show $1" # repo pass first arg
# Create Local Backups
- echo $(date) "Creating Local Backups ..."
+ echo "$(date) -- Creating Local Backups ..."
REPOSITORY=$2 # repo vault path second arg
shift 2 # consume the first 2 arguments
borg create --list --filter AME --stats --compression=lz4 \
@@ -30,25 +31,25 @@ backup_local() {
--exclude '*.elc' \
--exclude '*/.local/straight' \
--exclude '*/phd/simulation_data' \
- $REPOSITORY::'{hostname}-{user}-{utcnow:%Y-%m-%dT%H:%M:%S}' \
- $@ # all the dirs to bac
+ "$REPOSITORY::{hostname}-{user}-{utcnow:%Y-%m-%dT%H:%M:%S}" \
+ "$@" # all the dirs to bac
# Prune Local Backups
- echo $(date) "Pruning local repository ..."
+ echo "$(date) -- Pruning local repository ..."
borg prune --verbose --stats --list \
--glob-archives='{hostname}-{user}-*' \
--keep-daily 7 \
--keep-weekly 4 \
- --keep-monthly 6 $REPOSITORY
+ --keep-monthly 6 "$REPOSITORY"
}
-BASIC_PATHS=~/dev/ ~/org/ ~/.mail/ ~/.bogofilter/ ~/Nextcloud/
-backup_local Admin/sarah/borg/ingrid ssh://borgbackup@sarah/./repos/ingrid $BASIC_PATHS
+BASIC_PATHS=(~/dev/ ~/org/ ~/.mail/ ~/.bogofilter/ ~/Nextcloud/)
+backup_local Admin/sarah/borg/ingrid ssh://borgbackup@sarah/./repos/ingrid "${BASIC_PATHS[@]}"
DISK=/run/media/titan/ext_backup
if [ -d "$DISK" ]; then
- LARGER_PATHS="$DISK/personal/Pictures/" "$DISK/personal/Libros/" "$DISK/personal/dev/" "$DISK/Archives/"
- backup_local borgbackup ssh://backup/media/Backup/daily_backup/ $BASIC_PATHS $LARGER_PATHS
- backup_local Admin/sarah/borg/oscar ssh://borgbackup@sarah/./repos/oscar $LARGER_PATHS
+ LARGER_PATHS=("$DISK/personal/Pictures/" "$DISK/personal/Libros/" "$DISK/personal/dev/" "$DISK/Archives/")
+ backup_local borgbackup ssh://backup/media/Backup/daily_backup/ "${BASIC_PATHS[@]}" "${LARGER_PATHS[@]}"
+ backup_local Admin/sarah/borg/oscar ssh://borgbackup@sarah/./repos/oscar "${LARGER_PATHS[@]}"
fi