#export BORG_PASSPHRASE='HACKME'
#export BORG_PASSCOMMAND='pass show backup'
#export BORG_PASSCOMMAND='keyringer default decrypt borg 2> /dev/null'
-
- # Backup config
- keepdaily="7"
- keepweekly="4"
- keepmonth="6"
- encryption="keyfile"
- placeholder="{user}"
Then run borger:
#export BORG_PASSCOMMAND='pass show backup'
#export BORG_PASSCOMMAND='keyringer default decrypt borg 2> /dev/null'
- # Backup config
- keepdaily="7"
- keepweekly="4"
- keepmonth="6"
- encryption="keyfile"
- placeholder="{user}"
-
Then run borger normally:
borger my-disk
+# Optional config
+
+These include:
+
+ # Optional backup config
+ export KEEPDAILY="7" # how many days to keep
+ export KEEPWEEKLY="4" # how many weeks to keep
+ export KEEPMONTHLY="6" # how many months to keep
+ export ENCRYPTION="keyfile" # encryption strategy, PAY ATTENTION TO THIS
+ export PLACEHOLDER="{user}" # placeholder to tag archives
+ export INTERVAL="1h" # interval between backups in the continuous mode
+
+# Continuous backups
+
+If you want to run your backups continuously, use
+
+ borger servername --continuous
+
+By default `borger` waits `1h` before starting the new backup procedure which
+can be adjusted using the `INTERVAL` config variable. See [this
+issue](https://github.com/borgbackup/borg/issues/325) for a discussion on
+continous backups.
+
# Checking your backups
As simply as
}
function borger_usage {
- # Ensure we have our base config folder
- mkdir -p $BASE_CONFIG
-
- # List available targets
- if [ -z "$DESTINATION" ]; then
- echo "usage: $BASENAME <destination> [--check]"
- echo -n "available destinations from $BASE_CONFIG: "
- ls $BASE_CONFIG
- exit 1
- fi
+ echo "usage: $BASENAME <destination> [--continuous|--check]"
+ echo -n "available destinations from $BASE_CONFIG: "
+ ls $BASE_CONFIG
+ exit 1
}
# Config
fi
# Default backup config
- keepdaily="7"
- keepweekly="4"
- keepmonth="6"
- encryption="keyfile"
- placeholder="{user}"
+ KEEPDAILY="7"
+ KEEPWEEKLY="4"
+ KEEPMONTHLY="6"
+ ENCRYPTION="keyfile"
+ PLACEHOLDER="{user}"
+ INTERVAL="1h"
if [ -e "$CONFIG" ] ; then
source $CONFIG
# Check
function borger_check {
- if [ "$OPTION" == "--check" ]; then
- borg list
- exit $?
- fi
+ borg list
+ exit $?
}
# Our trap
# Remote backup over SSH
if ! ssh $SSH_SERVER -p $SSH_PORT test -f $BORG_REPO_DIR/config; then
info "Initializing borg repository at $BORG_REPO..."
- borg init --encryption=$encryption $BORG_REPO
+ borg init --encryption=$ENCRYPTION $BORG_REPO
init_exit=$?
# Local backup
if [ ! -f "$BORG_REPO/config" ]; then
info "Initializing borg repository at $BORG_REPO..."
- borg init --encryption=$encryption $BORG_REPO
+ borg init --encryption=$ENCRYPTION $BORG_REPO
init_exit=$?
--show-rc \
--compression lz4 \
--exclude-caches \
- ::"${placeholder}-{now}" \
+ ::"${PLACEHOLDER}-{now}" \
$ORIG
backup_exit=$?
}
# Use the `prune` subcommand to maintain daily, weekly and monthly archives.
-# The '${placeholder}-' prefix is very important to limit prune's operation to
+# The '${PLACEHOLDER}-' prefix is very important to limit prune's operation to
# one specific archive and not apply to archives also.
function borger_prune {
info "Pruning repository..."
borg prune \
--list \
- --prefix "${placeholder}-" \
+ --prefix "${PLACEHOLDER}-" \
--show-rc \
- --keep-daily $keepdaily \
- --keep-weekly $keepweekly \
- --keep-monthly $keepmonthly \
+ --keep-daily $KEEPDAILY \
+ --keep-weekly $KEEPWEEKLY \
+ --keep-monthly $KEEPMONTHLY \
prune_exit=$?
fi
}
-# Main
-borger_usage
-borger_config
-borger_check
-borger_trap
-borger_init
-borger_create
-borger_prune
+# Main backup procedure
+function borger_run {
+ borger_config
+ borger_trap
+ borger_init
+ borger_create
+ borger_prune
+}
+
+# Ensure we have our base config folder
+mkdir -p $BASE_CONFIG
+
+# Dispatch
+if [ -z "$DESTINATION" ]; then
+ borger_usage
+elif [ -z "$OPTION" ]; then
+ borger_run
+elif [ "$OPTION" == "--check" ]; then
+ borger_config
+ borger_check
+elif [ "$OPTION" == "--continuous" ]; then
+ while true; do
+ borger_run
+ info "Running on continous mode... sleeping $INTERVAL..."
+ sleep $INTERVAL
+ done
+fi