backup

A simple system backup utility
git clone git://git.danielmoch.com/backup.git
Log | Files | Refs

commit ca908d2ecdf55807620ed7c04999a2c475e76da5
parent 8859724b0562d903c42cdd48a95e89c4ac1bd7b6
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Fri, 22 Jun 2018 06:23:33 -0400

Add command-line support

Diffstat:
Mbackup | 24++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/backup b/backup @@ -1,4 +1,18 @@ #!/bin/sh +BACKUP_CONFIG=/etc/backup/config +BACKUP_PASSFILE=/etc/backup/passwd +BACKUP_DEST=/var/backup +BACKUP_FOLDERS=/etc\ /root\ /home + +while [ -n "$1" ] +do + [ "$1" = "-c" ] && shift && BACKUP_CONFIG=$1 + [ "$1" = "-i" ] && shift && BACKUP_INIT=1 && BORG_PASSPHRASE=$1 + shift +done + +[ -f "$BACKUP_CONFIG" ] && . "$BACKUP_CONFIG" + [ -n "$BACKUP_OUTPUT" ] && exec > $BACKUP_OUTPUT 2>&1 if [ $EUID -ne 0 ] then @@ -59,8 +73,14 @@ then fi fi -BORG_PASSPHRASE=`cat $PASSFILE` borg create \ - $BACKUP_MOUNTPOINT/$HOSTNAME.borg::`date '+%Y%m%d'` \ +if [ -n "$BACKUP_INIT" ] +then + echo "$BORG_PASSPHRASE" > $BACKUP_PASSFILE + borg init --encryption=authenticated "$BACKUP_DEST" +fi + +BORG_PASSPHRASE=`cat $BACKUP_PASSFILE` borg create \ + $BACKUP_DEST::`date '+%Y%m%d'` \ $BACKUP_FOLDERS 2>&1 __cleanup