备份脚本

[root@oldboy ~]# vim beifen.sh  
#!/bin/bash
tar zcf /root/tmp.tgz /tmp >>/dev/null  

if [ -f /root/tmp.tgz ];then       
   echo '备份成功' >> /tmp/beifen.log   
eles
   echo '备份失败' >> /tmp/beifen.log
fi                                   

vim beifen.sh
#!/bin/bash
D=$(date +%F-%R)
H=$(hostname)
mkdir -p /backup 
cd / && tar zcf /backup/${D}_$H.etc.tgz etc >/dev/null
if [ -f /backup/${D}_$H.etc.tgz ];then       
   echo '备份成功' >> /tmp/beifen.log   
eles
   echo '备份失败' >> /tmp/beifen.log
fi

posted @ 2020-05-01 14:23  看萝卜在飘  阅读(187)  评论(0编辑  收藏  举报