summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan DeMasi <jonathan.demasi@colorado.edu>2019-07-17 11:09:44 -0600
committerJonathan DeMasi <jonathan.demasi@colorado.edu>2019-07-17 11:09:44 -0600
commit6f8635b0797353da01134e4598cf05640213d597 (patch)
tree8702c014cd4ea00818aea439d4eff1f4bb9e7055
parent8d46bbbe1f170864b530552108c1ab0bffd231e2 (diff)
downloadconfigs-6f8635b0797353da01134e4598cf05640213d597.tar
configs-6f8635b0797353da01134e4598cf05640213d597.tar.gz
configs-6f8635b0797353da01134e4598cf05640213d597.tar.bz2
configs-6f8635b0797353da01134e4598cf05640213d597.tar.lz
configs-6f8635b0797353da01134e4598cf05640213d597.tar.xz
configs-6f8635b0797353da01134e4598cf05640213d597.tar.zst
configs-6f8635b0797353da01134e4598cf05640213d597.zip
borg sampleHEADmaster
-rw-r--r--borg/backup_sample.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/borg/backup_sample.sh b/borg/backup_sample.sh
new file mode 100644
index 0000000..8498ffe
--- /dev/null
+++ b/borg/backup_sample.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+export BORG_PASSPHRASE="YOURPASSPHRASEHERE"
+
+declare -i j=0
+MAX_TRIES=3
+
+for (( j = 0 ; j < ${MAX_TRIES} ; j++ ))
+ do
+ ping -c 1 YOURHOSTNAME.YOUR.TLD
+ if [[ "${?}" == '0' ]] ; then # connection success, so we continue.
+ break
+ else
+ sleep 15
+ fi
+ done
+
+if [[ "${j}" == '3' ]]; then
+ echo "No reliable connection, exiting!"
+ exit 1
+fi
+
+echo "Creating a new archive..." >> /root/logs/borg.log
+borg create --compression=lzma,9 --progress ssh://SSHUSER@YOURHOSTNAME:2222/home/SSHUSER/YOURUSER::YOURUSER-{now:%Y%m%d} /home/YOURUSER --exclude '/home/YOURUSER/.cache' >> /root/logs/borg.log 2>&1
+
+echo "Pruning archives..." >> /root/logs/borg.log
+borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=6 ssh://SSHUSER@YOURHOSTNAME:2222/home/SSHUSER/YOURUSER >> /root/logs/borg.log 2>&1