文件备份

#!/bin/sh

# $1 is the path to the files
# $2 is the prefix of the archive
# $3 is the which day ago to archive
# example
FILE_PATH=$1
PREFIX=$2
DAYS=$3

cd $FILE_PATH
/bin/ls -lrt $FILE_PATH | grep xml | grep "`date +"%b %e" --date="$DAYS days ago"`" | /bin/awk '{print $9}' | /bin/tar zcvf $FILE_PATH/$PREFIX.`date +"%Y%m%d" --date="$DAYS days ago"`.tar.gz --files-from -
/bin/ls -lrt $FILE_PATH | grep xml | grep "`date +"%b %e" --date="$DAYS days ago"`" | /bin/awk '{print $9}' | xargs /bin/rm

你可能感兴趣的:(文件)