dip

old school recipes for janitorial snafu.
git clone git://git.ricketyspace.net/dip.git
Log | Files | Refs

commit c5b282b4f4558ca1f0df492a1f4078fcdc8b5d6a
parent 5c798adce1c3304775eacc7ff6163f88371c8b64
Author: rsiddharth <s@ricketyspace.net>
Date:   Mon,  6 Aug 2018 03:32:44 +0000

usr/local/bin: Add rsync-bu.

Diffstat:
usr/local/bin/rsync-bu | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+), 0 deletions(-)

diff --git a/usr/local/bin/rsync-bu b/usr/local/bin/rsync-bu @@ -0,0 +1,63 @@ +#!/bin/bash +# +# License: CC0-1.0 +# +# Usage: +# +# $ rsync-bu +# +# + +parse_opts() { + export BFILE=$1 + if [ -z $BFILE ]; then + echo 'Backup info file not passed! Exiting.' + exit 1 + fi + if [ ! -f $BFILE ]; then + echo $BFILE 'does not exist! Exiting.' + exit 1 + fi +} + +parse_src() { + echo 'checking source...' + + if [ ! -d $1 ] && [ ! -f $1 ]; then + echo 'Source "'$1'" does not exists' + exit 1 + fi + + return 0 +} + +parse_dest() { + DIR=$(dirname $1) + if [ ! -d $DIR ]; then + echo 'Making '$DIR' ...' + mkdir -p $DIR + [[ $? == 1 ]] && exit 1 + fi + + return 0 +} + +bu() { + # Make Options + OPTS='-ravz --delete-excluded' + + SRC=${1/#\~/$HOME} + DEST=${2/#\~/$HOME} + + parse_src $SRC + parse_dest $DEST + + rsync $OPTS $SRC $DEST +} + +parse_opts $1 + +# Backup 'em all up +while read -r line; do + bu $line +done <$BFILE