[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