步骤:bash
1.肯定备份目标服务器list 服务器
2.肯定备份目标文件路径ui
3.制订备份策略rest
4.搭建rsync serverserver
5.生成执行备份脚本ip
6.saltstack分发脚本到备份目标服务器同步
7.saltstack批量配置cron计划任务到备份目标服务器io
8.在rsync server配置cron计划任务定时生成tar包存储到指定路径cli
1、肯定备份目标服务器list打包
PMC PMS LS
2、肯定备份目标文件路径
/etc/lis /etc/logstash /lib/systemd/system
3、备份策略
天天23点同步备份到rsync server
天天23::50 rsync server 打包备份文件 转移到目录 /opt/backup_tar/ 下
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#rsync tool
#rsync server installation
yum -y install rsync
vi /etc/rsyncd.conf
#####################################################
uid = rsync
gid = rsync
user chroot = no
max connections = 200
pid file = /var/run/rsyncd.pid
timeout = 300
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[backup]
path = /backup/
ignore errors
read only = false
list = false
auth users = rsync_backup
secrets file = /etc/rsync.passwd
#####################################################
echo 'rsync_passwd' > /etc/rsync.passwd
chmod 600 /etc/rsync.passwd
systemctl restart rsyncd && systemctl enable rsyncd
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
chmod +x config_backup.sh
#scripts for client
#!/bin/bash
#location /root/config_backup.sh
yum -y install rsync
systemctl restart rsyncd && systemctl enable rsyncd
if [ ! -f /etc/rsync.passwd ]; then
touch /etc/rsync.passwd
echo 'rsync_passwd' > /etc/rsync.passwd
else
echo 'rsync_passwd' /etc/rsync.passwd
fi
chmod 600 /etc/rsync.passwd
rsync -avzP /etc/lis rsync_backup@rsyncserver::backup/$HOSTNAME --password-file=/etc/rsync.passwd
rsync -avzP /lib/systemd/system rsync_backup@rsyncserver::backup/$HOSTNAME --password-file=/etc/rsync.passwd
rsync -avzP /etc/logstash rsync_backup@rsyncserver::backup/$HOSTNAME --password-file=/etc/rsync.passwd
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#file and script delivery(clients)
salt-cp '*' config_backup.sh /root/config_backup.sh
salt '*' cron.set_job root '0' '23' '*' '*' '*' '/usr/bin/bash /root/config_backup.sh'
#rsync server tar
50 23 * * * /usr/bin/bash /root/config_tar.sh
chmod +x /root/config_tar.sh
#####################################################
#!/bin/bash
cd /opt/backup_tar
tar -czPf `date +%Y-%m-%d`_config_backup.tar /backup
#####################################################
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++