40 lines
852 B
Bash
40 lines
852 B
Bash
![]() |
#!/bin/bash
|
||
|
|
||
|
[ -z "$SRC_DEVS" ] && echo "SRC_DEVS not set" && exit 1
|
||
|
[ ! -d "$SRC_DEVS/src/provisioning" ] && echo "src/provisioning not found in $SRC_DEVS" && exit 1
|
||
|
|
||
|
[ -z "$SAVE_DEVS" ] && echo "SAVE_DEVS not set" && exit 1
|
||
|
|
||
|
ORG=$(pwd)
|
||
|
NOW=$(date +%y%m%d)
|
||
|
SAVE_PATH="$SAVE_DEVS"
|
||
|
LIST="
|
||
|
klab
|
||
|
src/provisioning
|
||
|
"
|
||
|
|
||
|
[ "$1" == "-x" ] && OPS="v"
|
||
|
|
||
|
cd "$SRC_DEVS" || exit 1
|
||
|
|
||
|
for it in $LIST
|
||
|
do
|
||
|
root_path=$(dirname "$it")
|
||
|
name=${it//\//-}-$NOW
|
||
|
echo "Backup [$NOW] copy $it ..."
|
||
|
if [ "$root_path" == "." ] ; then
|
||
|
if tar c${OPS}zf "$SAVE_PATH/$name.tar.gz" $(basename "$it") ; then
|
||
|
echo "$it copied in $SAVE_PATH/$name.tar.gz"
|
||
|
fi
|
||
|
else
|
||
|
cd "$root_path" || exit 1
|
||
|
if tar c${OPS}zf "$SAVE_PATH/$name.tar.gz" $(basename "$it") ; then
|
||
|
echo "$it copied in $SAVE_PATH/$name.tar.gz"
|
||
|
fi
|
||
|
cd "$ORG" || exit 1
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
cd "$ORG"|| exit 1
|
||
|
|