Rsync 同步備份服務器重要配置文件

步驟: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

#####################################################

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

相關文章
相關標籤/搜索