Browse Source

prune: save password in an SSH agent, and compact after pruning

Since we want to run two commands, use a temporary SSH agent
to hold the key, so that the user only has to enter the password
once.
master
Jim Paris 2 days ago
parent
commit
6830daa2b1
2 changed files with 18 additions and 2 deletions
  1. +4
    -2
      initial-setup.sh
  2. +14
    -0
      prune.sh

+ 4
- 2
initial-setup.sh View File

@@ -89,8 +89,10 @@ export BORG_BASE_DIR=${BORG_DIR}
export BORG_CACHE_DIR=${BORG_DIR}/cache
export BORG_CONFIG_DIR=${BORG_DIR}/config
if [ "\$1" = "--rw" ] ; then
echo "=== Need SSH key passphrase. Check Bitwarden for:"
echo "=== borg $(hostname) / read-write SSH key"
if [ "$BORG_RW_KEY_ADDED" != "1" ] ; then
echo "=== Need SSH key passphrase. Check Bitwarden for:"
echo "=== borg $(hostname) / read-write SSH key"
fi
export BORG_RSH="ssh -F $SSH/config -o BatchMode=no -i $SSH/id_ecdsa"
shift
else


+ 14
- 0
prune.sh View File

@@ -3,10 +3,24 @@
BORG="$(dirname "$0")/borg.sh --rw"
set -e

if [ "$BORG_RW_KEY_ADDED" != "1" ] ; then
echo "Re-executing under a new ssh agent"
exec env BORG_RW_KEY_ADDED=1 ssh-agent "$0"
fi

echo "=== Please enter SSH key passphrase. Check Bitwarden for:"
echo "=== borg basis / read-write SSH key"
ssh-add -v "$(realpath "$(dirname "$0")")/ssh/id_ecdsa"

$BORG prune \
--verbose \
--progress \
--stats \
--keep-within=7d \
--keep-daily=14 \
--keep-weekly=8 \
--keep-monthly=-1

$BORG compact \
--verbose \
--progress

Loading…
Cancel
Save