|
去年写的脚本,后来有些小的改动。系统是freebsd4.7rel
发信人: windnee (风之子), 信区: FreeBSD
标 题: 系统备份用的脚本
发信站: BBS 水木清华站 (Sun Dec 29 13:49:53 2002), 转信
#/etc/crontab
......
#m h d mo w u c
30 6 * * * root /root/msh/daily_update__bakup.sh
1 6 1 * * root /root/msh/monthly_base_bakup.sh
......
#/root/msh/monthly_base_bakup.sh
#!/bin/sh
##################monthly bakup#########################
##############create file list##########################
echo "Start at" >> /mnt/bak/autobak/base_bak.log 2>&1
date >> /mnt/bak/autobak/base_bak.log 2>&1
find \
/ \
\( ! -type d \
-or \( -type d \
-and -empty \) \
\) \
-and \
! \( \
-path "/ftp/incoming/*" \
-or -path "/usr/ports/*" \
-or -path "/proc/*" \
-or -path "/tmp/*" \
-or -path "/cdrom/*" \
-or -path "/mnt/*" \
-or -path "/dist/*" \
-or -path "/var/run/*" \
\) \
-print \
> /mnt/bak/autobak/base_bak_list.txt
#################tar and gzip##################
tar -zcf /mnt/bak/autobak/base_bak.tar.gz \
-T /mnt/bak/autobak/base_bak_list.txt \
>> /mnt/bak/autobak/base_bak.log 2>&1
echo "End at" >> /mnt/bak/autobak/base_bak.log 2>&1
date >> /mnt/bak/autobak/base_bak.log 2>&1
#/root/msh/daily_update__bakup.sh
#!/bin/sh
##################daily update bakup##################
###################create file list###################
echo "Start at" >> /mnt/bak/autobak/base_bak.log 2>&1
date >> /mnt/bak/autobak/base_bak.log 2>&1
find \
/ \
\( -newer /mnt/bak/autobak/base_bak_list.txt \) \
-and \
\( ! -type d \
-or \( -type d \
-and -empty \) \
\) \
-and \
! \( \
-path "/ftp/incoming/*" \
-or -path "/usr/ports/*" \
-or -path "/proc/*" \
-or -path "/tmp/*" \
-or -path "/cdrom/*" \
-or -path "/mnt/*" \
-or -path "/dist/*" \
-or -path "/var/run/*" \
\) \
-print \
> /mnt/bak/autobak/update_bak_list.txt
###################bak old tar files##################
mv /mnt/bak/autobak/update_bak.tar.gz1 \
/mnt/bak/autobak/update_bak.tar.gz2 \
>> /mnt/bak/autobak/update_bak.log 2>&1
mv /mnt/bak/autobak/update_bak.tar.gz \
/mnt/bak/autobak/update_bak.tar.gz1 \
>> /mnt/bak/autobak/update_bak.log 2>&1
#####################tar and gzip#####################
tar -zcf /mnt/bak/autobak/update_bak.tar.gz \
-T /mnt/bak/autobak/update_bak_list.txt \
>> /mnt/bak/autobak/update_bak.log 2>&1
echo "End at" >> /mnt/bak/autobak/base_bak.log 2>&1
date >> /mnt/bak/autobak/base_bak.log 2>&1
-- |
|