LINUX: borg system backup

on debian:

apt install borgbackup

Client site:
Sytembackup using exclude dirs:

borg init -e repokey borg@backuphost.domain.de:/var/lib/backup/BACKUPREPO

 

#!/usr/bin/env bash

##
## Umgebungsvariablen
##

## set ssh key if needed
# export BORG_RSH="ssh -i /home/SOMEUSER/.ssh/id_ed25519"

## repository passphrase
export BORG_PASSPHRASE="SUPERSECRET"

## Host variables

LOG="/var/log/borg/backup.log"
BACKUP_USER="borg"
BACKUP_HOST="XXXBACKUP_SERVERXXX"
REPOSITORY_DIR="XXXLOCAL_HOSTNAMEXXX"

## build full repo path

REPOSITORY="${BACKUP_USER}@${BACKUP_HOST}:/var/lib/backup/${REPOSITORY_DIR}"

## Write Log

exec > >(tee -i ${LOG})
exec 2>&1

echo "###### Backup gestartet: $(date) ######"
TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`

echo "Übertrage Dateien ..."
borg create -v --stats                   \
	$REPOSITORY::${REPOSITORY_DIR}_${TIMESTAMP}  \
    /                                    \
    --exclude /dev                       \
    --exclude /proc                      \
    --exclude /sys                       \
    --exclude /var/run                   \
    --exclude /run                       \
    --exclude /lost+found                

echo "###### Backup beendet: $(date) ######"

usage in cron:

0 0 * * * /root/backup.sh > /dev/null 2>&1

termux borg backup with android

#!/bin/sh

#HOME="/storage/emulated/0/"
HOME="/"
BORG_REPO="my_mobile"

dirs="/"
dirs="/storage /data"

sudo borg create                               \
    --exclude-caches                      \
    --exclude-if-present "nobackup.tag"   \
    --exclude-if-present ".nobackup.tag"  \
    --progress                            \
    --stats                               \
    borg-backup@192.168.XX.XX:/mnt/BorgBackup/${BORG_REPO}/::'my-mobile-{now}' $dirs
    

sudo borg prune --stats --keep-within 14d --keep-daily 8 --keep-weekly 8 --keep-monthly 24 --keep-yearly -1 borg-backup@192.168.XX.XX:/mnt/BorgBackup/${BORG_REPO}/