Linux using iptables for remote backup/restore

  
                

In the Linuxp system, the itables command can perform a backup or restore for us, but many users may not be familiar with it. The following small series will share the method for everyone.

as follows:

1, iptables configuration file location: /etc /sysconfig /iptables

master: i.e. the business running the machine; backup Machine: When the main control machine fails, switch to the backup machine

--Operation on the main controller -------------------

2, create a directory:

mkdir -p /bak/iptables/

mkdir /root/script/

3, in the /root/script/directory Create a script:

vi backup.sh

\\cp /etc/sysconfig/iptables /bak/iptables/iptables_$(date +%Y%m%d%H)

4, custom automatic tasks:

crontab -e

*/10 * * * * /usr/sbin/ntpdate 210.72.145.44

10 * * * * Sh /root/script/backup.sh

--Operating on the backup machine ---------------------

5, Create directory:

mkdir -p /bak/iptables/{lt,yd} #lt directory to put backup of Unicom jump, yd directory put mobile jump backup

mkdir /root/Script/

6, in the /root/script/directory Create a script:

vi scp_lt.sh

#!/usr/bin/expect -f

set password gst

spawn scp -P 22 root @202.105.135.52:/etc/sysconfig/iptables /bak/iptables/lt/iptables

set timeout 300

expect "[email protected]'s password:"

set timeout 300

send "$password\ "

set timeout 300

send "exit\ "

expect Eof Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved