码迷,mamicode.com
首页 > 系统相关 > 详细

Linux shell : 史上最简单的系统备份脚本

时间:2016-06-06 17:15:51      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:linux   shell   bash   系统备份   

#!/bin/bash

# The is script backup /etc directory!

# Author: zhangjun (E-MAILL: bard_zhang@foxmail.com)

date=$(date +%y%m%d)
size=$(du -sh /etc)

if [ -d /tmp/dbbak ]
        then
                echo "Date: $date!" > /tmp/dbbak/dbinfo.txt
                echo "Size: $size!" >> /tmp/dbbak/dbinfo.txt
                cd /tmp/dbbak
                tar -zcf etc_$date.tar.gz /etc dbinfo.txt &> /dev/null
                rm -rf /tmp/dbbak/dbinfo.txt

        else
                mkdir /tmp/dbbak
                echo "Date: $date!" > /tmp/dbbak/dbinfo.txt
                echo "Size: $size!" >> /tmp/dbbak/dbinfo.txt
                cd /tmp/dbbak
                tar -zcf etc_$date.tar.gz /etc dbinfo.txt &> /dev/null
                rm -rf /tmp/dbbak/dbinfo.txt
fi


本文出自 “汜水流年_” 博客,请务必保留此出处http://timefiles.blog.51cto.com/8475652/1786625

Linux shell : 史上最简单的系统备份脚本

标签:linux   shell   bash   系统备份   

原文地址:http://timefiles.blog.51cto.com/8475652/1786625

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!