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

File backup scheme between servers, how to automatically back up server files to another server?

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Many organizations have the need for file server backup, and often automatically back up files from one server to another file server. How can it be realized?

1. The method of automatic backup of Windows file server

The simplest method of automatic backup of Windows file server is to install special server file automatic backup software. at present, there are some software specially used to backup server files in our country. For example, there is a "general trend to server file automatic backup system" (download address: http://www.grabsun.com/filebackup.html), which only needs to be installed on the server, you can make incremental backup and full backup of the server files, that is, you can automatically and regularly back up the server folders to other disk partitions of the server, external removable hard drives, other file servers or NAS storage space, etc. Thus effectively protect the security of server files and prevent the loss of server files. As shown in the following figure:

Figure: general trend to server file automatic backup software

At the same time, through the general trend to the server file automatic backup system can also achieve only one server files or folders and the corresponding account, all migrated to another server, thus avoiding the trouble of resetting the account and file access rights. As shown below:

Figure: server file migration

Of course, you can also do this through script commands. The details are as follows:

Some files of the project are uploaded to temporary files on the windows system and need to be backed up regularly. For example, I want to copy the D/information/images folder and all its files to the F/Archives folder as follows:

1. Create a new txt file and enter the following

Parameter explanation:

/ e: copy all subdirectories, including empty subdirectories; / I: if the destination file or directory does not exist and more than one file is copied, the target is assumed to be a directory / d: copy only the file date and the files after the target file (that is, the modified source file) / h: copy both hidden files and system files / r: copy and overwrite read-only files / y: copy file audit settings (do not show existing file overwrite confirmation)

2. After saving the text file, change the file to ".bat" file by renaming it.

3. In win10 system

Right-click at the beginning-- > computer Management-- > system tools-- > Task Scheduler-- > Task Scheduler Library-- > create tasks

In win7 system

Attachment-- > system tools-- > Task Scheduler-- create tasks

What is created here is executed at 9: 00 a. M. every day. After the creation is completed, refer to figure 3 to select the task and click the "run" button in the options to see the running effect.

If you need to trigger every N minutes, you need to set the trigger as follows (take every 10 minutes as an example)

2. The method of automatic backup of linux file server

1. State in advance:

Take establishing timing synchronization between two servers as an example, backup the content under the server A / home/jack path to the server B / home/test path.

Set the timing synchronization time to 5 minutes

2. Configuration process:

Server (that is, server A):

Install rsync:yum-y install rsync

Ln-s / etc/rsyncd.conf

Write the configuration file for rsync: vim rsyncd.conf

The resolution is as follows:

Uid = root # root user access (I use ROOT users here You can also use other newly created users) gid = root # root group users to access port=871 # through port 873 use chroot = yes # you can use chroot read only = no # readable / writable max connections = 4 # maximum number of connections list = no # do not list files pid file = / var/run/rsyncd.pid # this step does not have this file timeout = 900 lock file = / var/run/rsyncd .lock # this step does not have this file log file = / var/log/rsyncd.log # this step does not have this file [backup] # release item (note the name) comment = this is module for backup # module introduction Delete path = / home/jack/ # release path ignore errors auth users = root # authenticate the user as root secrets file = / etc/rsyncd.pass # password file

4. Write user password file: echo "root:111" > / etc/rsyncd.pass

(root: login user name set in the previous step; 111The password of the file is set at will, but remember that you need to use it next; this step creates the rsyncd.pass file)

Permission to modify password files (this step is important and can only be 600): chmod 600 / etc/rsyncd.pass

Start the rsyncd service

Service rsyncd start

View port occupied by process: netstat-tunlp

(after starting the rsyncd service, port 873 will be shown to be occupied by rsync)

Client (that is, server B):

1.yum-y install rsync

2.echo "root:123" > / etc/rsyncd/rsyncd.pass

(root: user name may not be written, if so, it must be the same as the user name set in step 3 of the server; 111password, required, and consistent with the password set in step 4 of the server)

3.chmod 600 / etc/rsyncd.pass

4. Create a path to store backup files: mkdir / home/backups

(the path is set at will)

5. Synchronize the files in the backup module directory in server A (we set / home/jack) to this ground floor (we set / home/backups) every 5 minutes

1 > ssh-keygen-t dsa-b 1024

2 > add the contents of id_dsa.pub to the authorized_keys file of B machine cat / root/.ssh/id_dsa.pub > > authorized_keys1

3 > create a script file that needs to be executed regularly, such as: rsyncd.sh script: vi / etc/rsyncd.sh (path is set by itself), and add the following to this script: (each meaning of the command is explained at the end of the document)

Rsync-auv-- password-file=/etc/rsyncd.passroot@192.168.22.99::backup / home/test/

4 > set the execution time of the script: crontab-e, add the following

* / 5 * sh / etc/rsyncd.sh # perform synchronization once in the 5th minute

At this point, the synchronization configuration is basically complete, which is normally synchronized every 5 minutes.

You can also enter the synchronization command directly to check whether it can be synchronized. The command format is:

Rsync command format: rsync [option] source path destination path

For example: synchronize the files to be backed up under the server A backup module to the local / home/test directory:

Rsync-auv-- password-file=/etc/rsyncd.passroot@192.168.22.99::backup / home/test/

Under normal circumstances, the above information is displayed when the synchronization is successful.

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