CentOS系统备份脚本详解

2025-05-27 0 75

#!/bin/sh

#设定变量

bak_path=/root/bak_linux

date=$(date +%Y%m%d)

log_file=$bak_path/$date#log.log

#把执行结果写到日志中

exec 1>>$log_file 2>&1

#把要备份的目录打包放到$bak_path目录下

tar -zcvf $bak_path/$date#boot.tar.gz /boot

tar -zcvf $bak_path/$date#etc.tar.gz /etc

tar -zcvf $bak_path/$date#var.tar.gz /var

echo "############\\n"

echo $?

#上传备份文件

ftp -i -n -v << FTPIT

open 192.168.0.27

user 111 111

binary

lcd $bak_path

mput *.tar.gz

put *#log.log

by

FTPIT

echo "############\\n"

echo $?

#删除上传完毕的.tar和.log文件

rm -rf $bak_path/*#*.tar

rm -rf $bak_path/*#log.log

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 CentOS系统备份脚本详解 https://www.kuaiidc.com/57236.html

相关文章

发表评论
暂无评论