If you are looking for software to use, go to Huajun Software Park! software release

How to use iptables for remote backup/restore in Linux

Author: Xiaoqiao Liushui Date: 2017-05-05

GCC For Linux
GCC For Linux-4.9.1 official version

Programming development Storage size: 85.54MB Time: 2010-08-02

Software introduction: GCC compiler suite (GNU Compiler Collection) includes C, C++, Objective-C, Fortran, Java, Ada and Go language...

Download now

In the Linuxp system, the itables command can perform remote backup or recovery for us, but many users may not be familiar with it yet. The editor will share the method with you below.

How to use iptables for remote backup/restore in Linux

Here's how:

1. Configuration file location of iptables: /etc/sysconfig/iptables

Main control machine: the machine that is running the business; backup machine: when the main control machine fails, it switches to the backup machine

--Operation on the main control computer------------------

2. Create a directory:

mkdir -p /bak/iptables/

mkdir /root/script/

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

vi backup.sh

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

4. Customize automatic tasks:

crontab -e

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

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

--Operate on the backup machine---------------------

5. Create a directory:

mkdir -p /bak/iptables/{lt,yd} #The lt directory stores the backup of China Unicom jump, and the yd directory stores the backup of mobile jump.

mkdir /root/script/

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

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 "root@202.105.135.52's password:"

set timeout 300

send "$passwordr"

set timeout 300

send "exitr"

expect eof

                   Okay, the above is all the content brought to you by the editor of Huajun. Isn’t it very simple? Have you learned it? If you want to know more related content, please pay attention to Huajun information at any time. Welcome to Huajun to download!

Related articles