Incremental backup of websites using rsync (from linux to windows)

  
                  

When using VPS before, including personal websites such as this blog, you usually use FTP script to use FTP backup (see my previous blog for details). The advantage of this method is simple and fast. However, when I made a backup to the company's website recently, I encountered a lot of problems. The company's website has a large amount of data, and there are more than 30 G. If I use FTP backup, it took me a whole morning, more serious. If the backup data is satisfied for 3 days, the disk space will skyrocket; if it is set to automatic backup, the hard disk will compress 30G data every day, and then transfer to the backup server. I am worried that the hard disk will hang in less than half a month!

When doing database management, when you encounter large backup data, you can perform incremental backup. Although the principle is the same, but you have not touched the file incremental backup, fortunately we have GOOGLE, reference Some commonly used online website backup methods, found an open source software rsync;

Its characteristics are as follows:

1, can save the entire directory tree and file system.

2, can easily maintain the original file permissions, time, soft and hard links and so on.

3, can be installed without special permissions.

4, optimized process, file transfer efficiency.

5, you can use rcp, ssh, etc. to transfer files, of course, you can also connect through a direct socket.


The company's website server is linux, and the backup server is windows. It does not need to consider real-time backup, so you can back up every day. The specific method is as follows:

1 First install rsync on the linux server,
#wget http://rsync.samba.org/ftp/rsync/rsync-3.0.8.tar.gz#tar zxvf rsync-3.0.8.tar.gz# Cd rsync-3.0.8#./configure#make#make install

2. Create rsyncd configuration file /etc/rsyncd.conf on vps, as follows:
uid = root # What is the backup? , User IDgid = root # What is the identity of the backup, group ID # Note this user ID and group ID, if it is convenient, you can set it to root, so rsync can almost # to read any files and directories, but also Bring security risks. It is recommended to set up to read only the directories and files you want to prepare. #use chroot = nomax connections = 0 # Maximum number of connections is not limited pid file = /var/log/rsync/rsyncd.pidlock file = /var/log/rsync/rsync.locklog file = /var/log/rsync/rsyncd. Log[web] # Specify the name of the certified backup module path = /home/# The directory to be backed up comment = BACKUP wwwroot # Comments ignore errors # Ignore some extraneous IO errors read only = false # Set to read only list = false # No Allow column file #hosts allow = 210.51.0.80 #Allow host IP address to connect to the server#hosts deny = 0.0.0.0/0.0.0.0 #Disable the host IP address of the connection server #auth users = wwek #Authenticated user name, if not This line indicates that it is anonymous (recommended to use anonymous, with the specified operation to run a single IP address backup) secrets file = /etc/rsyncd.secrets # Authentication file name, used to store the password

3. Since the password file is specified The file can only be read and written by the root user. Note that for security purposes, the attributes of this file must be readable by the owner, otherwise rsync will refuse to run. We can set its property to 600:
# chmod 600 /etc/rsyncd.secrets# mkdir /var/log/rsync

4. Start the rsyncd service on the server:
# /usr/local/bin /rsync –daemon

5.windows installation configuration cwrsync client cwrsync is rsync on windows.

Then execute the backup command

rsync -vzrtopg –progress –delete [server IP]::web [/cygdrive/f/backup]

where web is the server The module name in the configuration file, /cygdrive/f/backup means backup to local F:/backup

Copyright © Windows knowledge All Rights Reserved