dotfiles

config files and scripts at HOME.
git clone git://git.ricketyspace.net/dotfiles.git
Log | Files | Refs

commit d8cc84ddff0ae1c3958449331a1532561b99bb27
parent 217c3cd5e25513ea22fcec44533ac0cfaf99f111
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu,  5 Apr 2018 22:42:26 +0000

.bin/rsync-bu-to: Update license header.

Diffstat:
.bin/rsync-bu-to | 66++++++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 40 insertions(+), 26 deletions(-)

diff --git a/.bin/rsync-bu-to b/.bin/rsync-bu-to @@ -1,33 +1,47 @@ #!/bin/sh # -# Copyright (C) 2016 rsiddharth <s@ricketyspace.net> +# Copyright © 2016-2018 rsiddharth <s@ricketyspace.net> # -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. +# License: GPL-3.0-or-later # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. +# Usage: # -# You should have received a copy of the GNU General Public License -# along with this program (see COPYING). If not, see -# <http://www.gnu.org/licenses/>. - -# filter path -FILTER=$1 -# source path -SRC_PATH=$2 -# rsync-bu-to path -BACKUP_PATH=$3 - -if [ -d $BACKUP_PATH ]; then - echo 'rsyncing from' $SRC_PATH 'to' $BACKUP_PATH '...' - rsync -ravz --delete-excluded --files-from=$FILTER $SRC_PATH $BACKUP_PATH - echo 'finished rsyncing from ' $SRC_PATH 'to' $BACKUP_PATH -else - echo $BACKUP_PATH 'not found.' +# $ rsync-bu src-path backup-path [ files-from-file ] [ exclude-from-file ] +# +# + +SRC_PATH=$1 +if [ ! -d $SRC_PATH ]; then + echo 'Source directory '$SRC_PATH' not found' + exit 1 +fi + +BACKUP_PATH=$2 +if [ ! -d $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 '...' +echo $OPTS $SRC_PATH $BACKUP_PATH +echo 'finished rsyncing from ' $SRC_PATH 'to' $BACKUP_PATH +