aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-23 12:44:36 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-23 12:44:36 -0300
commitcc6feac775f15a091800a36a131d90fcaa25713d (patch)
tree0093c4aa378b7e994b0220103010efea8f038dd3
parent1139766b616a057f884397b85997c31a03c24bec (diff)
downloadborger-cc6feac775f15a091800a36a131d90fcaa25713d.tar.gz
borger-cc6feac775f15a091800a36a131d90fcaa25713d.tar.bz2
Support for local backups
-rw-r--r--README.md55
-rwxr-xr-xborger27
2 files changed, 60 insertions, 22 deletions
diff --git a/README.md b/README.md
index 55398d1..c358987 100644
--- a/README.md
+++ b/README.md
@@ -12,35 +12,58 @@ A script for home folder backups using [Borg](https://borgbackup.readthedocs.io)
Create a config for your `servername` destination at `~/.config/borger/servername`:
- # Backup destination
- export SSH_SERVER="user@host"
- export SSH_PORT="2202"
+ # Backup destination
+ export SSH_SERVER="user@host"
+ export SSH_PORT="2202"
- # Repository path
- export BORG_REPO_DIR="/var/backups/users/$USER/borg"
- export BORG_REPO="ssh://$SSH_SERVER:$SSH_PORT/$BORG_REPO_DIR"
+ # Repository path
+ export BORG_REPO_DIR="/var/backups/users/$USER/borg"
+ export BORG_REPO="ssh://$SSH_SERVER:$SSH_PORT/$BORG_REPO_DIR"
- # Setting one of those, so you won't be asked for your repository passphrase:
- #export BORG_PASSPHRASE='HACKME'
- #export BORG_PASSCOMMAND='pass show backup'
- #export BORG_PASSCOMMAND='keyringer default decrypt borg 2> /dev/null'
+ # Setting one of those, so you won't be asked for your repository passphrase:
+ #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}"
+ # Backup config
+ keepdaily="7"
+ keepweekly="4"
+ keepmonth="6"
+ encryption="keyfile"
+ placeholder="{user}"
Then run borger:
borger servername
+If you want to backup to local folder or a locally-mounted USB disk, use the
+following config at `~/.config/borger/my-disk`:
+
+ # Repository path
+ export BORG_REPO="/media/my-disk/backups/users/$USER/borg"
+
+ # Setting one of those, so you won't be asked for your repository passphrase:
+ #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 normally:
+
+ borger my-disk
+
# Checking your backups
As simply as
borger servername --check
+ borger mydisk --check
# WARNING
diff --git a/borger b/borger
index 2148986..0b1ac29 100755
--- a/borger
+++ b/borger
@@ -88,14 +88,29 @@ function borger_trap {
# Initialize
function borger_init {
- 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
+ if [ ! -z "$SSH_SERVER" ]; then
+ # 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
- init_exit=$?
+ init_exit=$?
- if [ "$init_exit" != "0" ]; then
- fatal "Error initializing repository"
+ if [ "$init_exit" != "0" ]; then
+ fatal "Error initializing repository"
+ fi
+ fi
+ else
+ # Local backup
+ if [ ! -f "$BORG_REPO/config" ]; then
+ info "Initializing borg repository at $BORG_REPO..."
+ borg init --encryption=$encryption $BORG_REPO
+
+ init_exit=$?
+
+ if [ "$init_exit" != "0" ]; then
+ fatal "Error initializing repository"
+ fi
fi
fi
}