With Rsync, achieve incremental deployment site

The entire site tend to be large, especially where a static picture video and the like, but we usually do not modify them, usually only change a few files, if each update the entire site to upload from the local to the server, no doubt very expensive time, if you want to find the modified files, and upload those files only, or even just upload some of these modified files will no doubt be a lot easier.

This use to today's protagonist Rsync , Rsync can perform incremental backups, only inconsistencies between source and target files transfer part

surroundings:

web server root directory /usr/share/nginx/game.shaochenfeng.com
local project directory /git/game.shaochenfeng.com/public

First, it proposes to configure the local web server ssh password-free login [how? ] (), Since a password is not synchronized configuration requires each

1. Install a web server rsync

Yum apt directly or can be installed, both locally and on the server side to install

yum install rsync # 红帽系
apt install rsync # Debian系

Why should it be installed rsync server? Because although the link is established through ssh, but rsync using their own transport rules, rather than scp

2. Push the server

Performed locally, the local project directory synchronization to the web server root directory

rsync -avz --delete <本地路径> [email protected]:<远程路径>
rsync -avz --delete /git/game.shaochenfeng.com/public [email protected]:/usr/share/nginx/game.shaochenfeng.com

Where the parameter

  • -a is recursive transfer and maintain the file attributes, when used with a transfer folder, and retain the properties file
  • -v display transmission
  • -z compression transmission, improve efficiency
  • --delete delete the local file, the server will be deleted

Attach rsync common options

-a comprising -rtplgoD
-R & lt synchronization with a recursive transfer folder using file
-v displaying transmission
-l flexible connector retention
-p property rights held
-o owner holding
-g holding is a group
-D file information holding device
-t holding file the time attribute, this must be, otherwise the next synchronization can not determine what files have to modify
the file already exists --backup server to do a backup, the backup file name defaults to "~" added
--delete delete local file, the server will be deleted
--exclude filter specified file, such as --exclude "logs" will contain the file name of the file or directory logs filtered out of sync
-P display synchronization process, such as rate, than -v in more detail
later add the -u option if DEST files than the new SRC, no synchronization
--size-only default algorithm checks the modification time and file size, add this just checks the file size
-z compression transmission, Improve efficiency

Welcome to my official website to view the operation and maintenance of technical articles www.shaochenfeng.com

Guess you like

Origin blog.51cto.com/6667965/2472632