dip

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

commit e6780bdc5a08cbdb8caa281d72c5ee87b2616e17
parent 4833a98cadc3bd24174a2a27f01f86ffca028b03
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 24 May 2018 22:16:50 +0000

usr: Add rsync-bu-to (from dotfiles).

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

diff --git a/usr/local/bin/rsync-bu-to b/usr/local/bin/rsync-bu-to @@ -0,0 +1,47 @@ +#!/bin/sh +# +# Copyright © 2016-2018 rsiddharth <s@ricketyspace.net> +# +# License: BSD2 +# +# Usage: +# +# $ rsync-bu-to src-path backup-path [ files-from-file ] [ exclude-from-file ] +# +# + +SRC_PATH=$1 +if [ -z $SRC_PATH ]; then + echo 'Source directory '$SRC_PATH' not found' + exit 1 +fi + +BACKUP_PATH=$2 +if [ -z $BACKUP_PATH ]; then + echo 'Backup directory '$BACKUP_PATH' not found' + exit 1 +fi + + +# Make Options +OPTS='-ravz --delete-excluded' + +if [ ! -z $3 ] && [ ! -f $3 ]; then + echo 'File '$3' not found' + exit 1 +elif [ ! -z $3 ] && [ -f $3 ]; then + OPTS=$OPTS' --files-from='$3 +fi + +if [ ! -z $4 ] && [ ! -f $4 ]; then + echo 'File '$4' not found' + exit 1 +elif [ ! -z $4 ] && [ -f $4 ]; then + OPTS=$OPTS' --exclude-from='$4 +fi + +# Sync 'em +echo 'rsyncing from' $SRC_PATH 'to' $BACKUP_PATH '...' +rsync $OPTS $SRC_PATH $BACKUP_PATH +echo 'finished rsyncing from ' $SRC_PATH 'to' $BACKUP_PATH +