code:
1 #!/bin/sh
2
3 #Some variables
4 BKD="/home/naigovan/" #BKD - A directory to backup
5 SRCD="/var/backups/tmp" #SRCD - SouRCe Directory
6 TGTD="/var/backups/" #TGTD - TarGeT Directory
7 MAXAGE=15 #Maximum age of files to backup
8 OF=backup-$(date +%Y%m%d).tgz #OF - Output File
9
10 # Main body
11
12 [ -d "$SRCD" -a "x`find $SRCD | wc -l`" != "x0" ] && find $SRCD | xargs rm -rf
13 [ ! -d "$SRCD" ] && mkdir -p "$SRCD"
14 find $BKD -atime $MAXAGE -type f | while read FILE
15 do
16 FILE_DIR="`echo $FILE | sed -e 's#^$INITIAL_DIR##' -e 's/\(.*\)\/[^\/].*$/\1/'`"
17 [ ! -d "$SRCD/$FILE_DIR" ] && mkdir -p $SRCD/$FILE_DIR
18 cp $FILE $SRCD/$FILE_DIR
19 done
20 tar -czf $TGTD$OF $SRCD
21 rm -rf $SRCD
Страницы: [1] 2 3 .... 10 | Следующие 30» |