ls方式备份脚本


#!/bin/bash


Name=`hostname`

Date=`date +%Y%m%d`

Date2=`date +%Y%m%d -d "30 day ago"`


BASE_DIR="/space/hudson/jobs"

DEST_DIR="/backup1/Hudson_cfgbak/$Name/$Date"


/bin/mkdir -p /backup1/Hudson_cfgbak/$Name/$Date

/bin/rm -rf /backup1/Hudson_cfgbak/$Name/$Date2


cd ${BASE_DIR}


for Job in $(ls)

do

if [ -d $Job ];then

if [ -f $Job/config.xml ];then

if [ -d "${DEST_DIR}/$Job" ];then

/bin/cp $Job/config.xml ${DEST_DIR}/$Job/

else

mkdir -p ${DEST_DIR}/$Job

/bin/cp $Job/config.xml ${DEST_DIR}/$Job

fi

fi

fi

done 


本文出自 “linux” 博客,谢绝转载!

你可能感兴趣的:(ls,备份脚本)