aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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