Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Rsync full network backup

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Rsync full network backup

1. First check whether there is a rsync service in the server

View method: use rpm-qa | grep "rsync" to check whether it already exists.

If it doesn't exist, download and install it with yum install rsync-y.

two。 Start the rsync process on the backup server side.

Startup method: rsync-daemon

Then check whether the process enables ps-ef | grep "rsync"

3. Create a virtual user reync without specifying a home directory

Create mode useradd-s / sbin/nologin/-M rsync

Use tail / etc/passwd to see if the rsync user has been created.

4. Create a configuration file in the / etc/rsyncd.conf file on the server side. The contents of the document are as follows:

# rsyncd.conf start#

Uid = rsync # # specify the specified users and user groups when the rsync service is running

Gid = rsync## specifies the specified users and user groups when the rsync service is running

Use chroot = no # prevent security problems

Max connections = 200 # maximum connections

Timeout = 300 # timeout

Pid file = / var/run/rsyncd.pid # stores the id number of the service runtime process (pid)

Lock file = / var/run/rsync.lock # lock file for the process

Log file = / var/log/rsyncd.log # log file

[backup] # Module name

Path = / backup/ # module corresponding location (or path)

Ignore errors #-ignore errors

Read only = whether false# is read-only

List = false # whether the list is allowed

Hosts allow = 172.16.1.0 hosts allow 24 # the range of customers who are allowed to access the rsync server

# hsts deny = 0.0.0.0Universe generally does not set the scope of customers that prohibit access to the reync server.

Auth users = rsync_backup # users who do not exist, open the door to the user (authentication)

Password for users whose secrets file= / etc/rsync.password # does not exist (entry)

# reync_config_end

The above configuration file is pushed to the backup service backup by a single client.

Multi-server push backup uses the following configuration file to add the corresponding server:

# rsyncd.conf start#

Uid = rsync # # specify the specified users and user groups when the rsync service is running

Gid = rsync## specifies the specified users and user groups when the rsync service is running

Use chroot = no # prevent security problems

Max connections = 200 # maximum connections

Timeout = 300 # timeout

Pid file = / var/run/rsyncd.pid # stores the id number of the service runtime process (pid)

Lock file = / var/run/rsync.lock # lock file for the process

Log file = / var/log/rsyncd.log # log file

Ignore errors #-ignore errors

Read only = whether false# is read-only

List = false # whether the list is allowed

Hosts allow = 172.16.1.0 hosts allow 24 # the range of customers who are allowed to access the rsync server

Hsts deny = 0.0.0.0amp 3pm generally does not set the customer scope that forbids access to the reync server.

Auth users = rsync_backup # users who do not exist, open the door to the user (authentication)

Password for users whose secrets file= / etc/rsync.password # does not exist (entry)

[backup] # Module name

Path = / backup/ # module corresponding location (or path)

[nfs01backup] # added second module

Path = / nfs01backup/# the corresponding position of the second module

# reync_config_end

5. Create a backup directory under the root directory of the backup server. (if multiple servers are backing up on this server, add the corresponding module path in the configuration file.)

Use the command mkdir-p / backup to create the backup directory of the first backup server.

If multiple modules are created in turn. (as long as the file path created here is the same as in the configuration file).

6. Change the user owner and group of the directory created above under the root directory. Change to rsync.

Using the command chown rsync.rsync / backup, the rsync user corresponding to the backup directory here should be exactly the same as the uid=rsync;gid=rsync in the configuration file and the virtual user rsync you just created. This refers to a virtual user.

7. Set the password for the file:

On the server side. The corresponding password is written in the / etc/rsync.password file on the backup side. The password format is as follows:

Echo "rsync_backup:123456" > / etc/rsync.password

The rsync_backup writing here must be consistent with that in the configuration file.

Then change the file permissions to 600.

Use the command chmod 600 / etc/rsync.password to modify

8. Switch to the client. That is, web01, or nfs01 server. Make the following modifications.

1. Write the password in the directory / etc/rsync.password file (the password here is the password used to access the backup server. To work with the server side. That is, the password in the / etc/rsync.password on the backup side is the same. But just write the password. There is no module correspondence.)

Execute the following command to make changes.

Echo "123456" > / etc/rsync.password

Then check to see if the password has been appended.

Use cat / etc/rsync.password

Change the permissions of this file to 600

Command:

Chmod 600 / etc/rsync.password

9. Use the command to push the content for backup. The following is how to perform without entering a password:

Rsync-avz / var rsync_backup@172.16.1.41::backup-- password-file=/etc/rsync.password

This command means to use the rsync command to push and back up the / var directory itself and all the files below.

The target of the push is the backup module below 172.16.1.41. The password is from / etc/rsync.password.

Because of the uid=rsync,gid=rsync in the configuration file, only the virtual user rsync on the backup server can operate on the file itself.

10. The above is a server for backup processing. If there are multiple servers for the same reason. What has changed is to back up the server-side configuration file. And the newly created password file for the client server. The rest remains the same.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report