LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 473|回复: 1

再问文件系统的问题

[复制链接]
发表于 2009-4-2 19:45:51 | 显示全部楼层 |阅读模式
有什么脚本可以实现这样的功能?几天前存在的文件,现在已经却已经被删除了。我想知道这个被删除的文件名字是什么。主要是用于备份用途。
 楼主| 发表于 2009-4-4 11:39:41 | 显示全部楼层
求天,求地,求人,不如求自己。本着“自己动手,丰衣足食”的原则。写了以下的这个脚本。主要实现功能是第一次运行该脚本时,产生一个“基准”备份点,以后每次运行这个脚本时都会跟这个“基准”点比较,实现增量,差异,“减量”备份。当然也可以稍作修改,使之每次备份是跟上一次对比。
#!/bin/sh
#yum clean all
backupdir="/bt/test"
if [ ! $1 == "" ];then
        destdir=$1
else
        destdir="/media/DATA_5/"
fi
echo "Save Partition :"$destdir
echo "Now , backup system .........>>>>>>>"
if [ -d $destdir ] ;then
#        destdir="/media/DATA2/"
        diskfree=`df -h $destdir |grep dev |sed -e 's/[[:space:]][[:space:]]*/ /g'|cut -d' ' -f4|cut -d'G' -f1`
        echo "Target Disk $destdir has "$diskfree"G free"
        diskfree=`echo "$diskfree*10" |bc |cut -d"." -f1`       
        #echo "diskfree"$diskfree
        if [ $diskfree -gt "43" ];then       
            tree $backupdir -f -I "mnt|proc|media|home|root|btdown|tmp|sys|dev|tmp|squid|clientmqueue" -o "$destdir"tree.txt
            if [ -f "$destdir"snapshot.org ];then
                 cp "$destdir"snapshot.org "$destdir"snapshot   
                 diff "$destdir"tree.txt "$destdir"tree.txt.org >"$destdir"diff.txt
                 tar -g "$destdir"snapshot -jcf "$destdir"fc9_backup_inc.tar.bz2 $backupdir --exclude=/mnt/* --exclude=/proc/* --exclude=/media/* --exclude=/home/* --exclude=/root/* --exclude=/btdown/* --exclude=/tmp/* --exclude=/sys/* --exclude=/dev/* --exclude=/var/tmp/* --exclude=/var/spool/squid/* --exclude=/var/spool/clientmqueue/*
#--exclude=/var/log/*.* --exclude=/var/cache/*
             else
                  tar -g "$destdir"snapshot -jcf "$destdir"fc9_backup.tar.bz2 $backupdir --exclude=/mnt/* --exclude=/proc/* --exclude=/media/* --exclude=/home/* --exclude=/root/* --exclude=/btdown/* --exclude=/tmp/* --exclude=/sys/* --exclude=/dev/* --exclude=/var/tmp/* --exclude=/var/spool/squid/* --exclude=/var/spool/clientmqueue/*
#--exclude=/var/log/*.* --exclude=/var/cache/*
                cp "$destdir"snapshot "$destdir"snapshot.org
                cp "$destdir"tree.txt "$destdir"tree.txt.org
                echo "slite the gz file to rar ........>>>"
                cd $destdir
                rar a -m0 -v920m fc9_bkg.rar fc9_backup.tar.bz2
              fi
                echo "finish.......<>>"
        else
                echo "Disk not Enough...."
        fi
else
        echo "$destdir is not an available directory.."
fi
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表