mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
translated
This commit is contained in:
parent
e3782e8f1f
commit
0d692e2703
@ -1,113 +0,0 @@
|
||||
Translating----geekpi
|
||||
|
||||
How to use Rsync Command In Linux With Examples
|
||||
================================================================================
|
||||
For organization and companies, data is most important for them, even specially E-commerce business, data is very critical to them. Rsysnc is tool or software which helps taking backup of critical data over the network. It also network protocol for Unix-like and Windows systems that synchronizes files and directories from one system to another system over the network. Rsysnc can copy or display directory and copy files. Rsysncd listens the defaults TCP port 873, copying files via a remote shell such as rsh or ssh. Rysync package must be installed on both remote system as well as local machine.
|
||||
|
||||
The main advantages of the rsysnc is :
|
||||
|
||||
**Speed**: Initially copies the whole content between local and remote system. Next time, it transfers only the changed blocks or bytes to the destination.
|
||||
|
||||
**Security**: Encrypted form of data can be transferred using ssh protocol.
|
||||
|
||||
**Less Bandwidth**: rsysnc uses compression and decompression of data block by block at both the end.
|
||||
|
||||
Syntax:
|
||||
#rsysnc [options] source path destination path
|
||||
|
||||
### Example: 1 - Enable Compression ###
|
||||
|
||||
[root@localhost /]# rsync -zvr /home/aloft/ /backuphomedir
|
||||
building file list ... done
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
sent 472 bytes received 86 bytes 1116.00 bytes/sec
|
||||
total size is 324 speedup is 0.58
|
||||
|
||||
In above command rsysnc uses –z for enable compression, -v for verbose, -r for recursive. Here above command synchronizes two directory /home/aloft/ and /backuphomedir in local system.
|
||||
|
||||
### Example: 2 - Preserve File/Directory Attributes ###
|
||||
|
||||
[root@localhost /]# rsync -azvr /home/aloft/ /backuphomedir
|
||||
building file list ... done
|
||||
./
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
|
||||
sent 514 bytes received 92 bytes 1212.00 bytes/sec
|
||||
total size is 324 speedup is 0.53
|
||||
|
||||
Above example we used –a option, it preserves owner and groups, it preserve timestamp, symbolic links, permission, recursive mode.
|
||||
|
||||
### Example: 3 - Synchronize local to remote host ###
|
||||
|
||||
root@localhost /]# rsync -avz /home/aloft/ azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/
|
||||
Password:
|
||||
|
||||
building file list ... done
|
||||
./
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
sent 514 bytes received 92 bytes 1212.00 bytes/sec
|
||||
total size is 324 speedup is 0.53
|
||||
|
||||
Above command allow you synchronize between local machines to remote machine. You can see , while synchronizing files to another system, it asks password. While doing synchronization with the remote server, you need to specify user name and IP or Hostname of the remote system.
|
||||
|
||||
### Example: 4 - Synchronize remote to local host ###
|
||||
|
||||
[root@localhost /]# rsync -avz azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/ /home/aloft/
|
||||
Password:
|
||||
building file list ... done
|
||||
./
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
sent 514 bytes received 92 bytes 1212.00 bytes/sec
|
||||
total size is 324 speedup is 0.53
|
||||
|
||||
Above command will synchronizes files from remote to local system
|
||||
|
||||
### Example: 5 - Find difference in files ###
|
||||
|
||||
[root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/
|
||||
building file list ... done
|
||||
cd+++++++ backuphomedir/
|
||||
>f+++++++ backuphomedir/.bash_logout
|
||||
>f+++++++ backuphomedir/.bash_profile
|
||||
>f+++++++ backuphomedir/.bashrc
|
||||
>f+++++++ backuphomedir/abc
|
||||
>f+++++++ backuphomedir/xyz
|
||||
|
||||
sent 650 bytes received 136 bytes 1572.00 bytes/sec
|
||||
total size is 324 speedup is 0.41
|
||||
|
||||
Above command helps to find any differences in the files or directories between source and destination
|
||||
|
||||
### Example: 6 - Take backup ###
|
||||
|
||||
rsync command could be used take linux backup.
|
||||
|
||||
You can schedule backup in cron using rsync command
|
||||
|
||||
0 0 * * * /usr/local/sbin/bkpscript &> /dev/null
|
||||
|
||||
----------
|
||||
|
||||
vi /usr/local/sbin/bkpscript
|
||||
|
||||
rsync -avz -e ‘ssh -p2093′ /home/test/ root@192.168.1.150:/oracle/data/
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/how-tos/rsync-copy/
|
||||
|
||||
作者:[Bobbin Zachariah][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/bobbin/
|
@ -0,0 +1,111 @@
|
||||
如何在Linux下使用Rsync
|
||||
================================================================================
|
||||
对于组织和公司,数据对他们是最重要的,即使对于电子商务,数据也是同样重要的。Rsync是一款通过网络备份重要数据的工具或者软件。它同样是一个在类Unix和Window系统上通过网络在系统间同步文件夹和文件的网络协议。Rsync可以复制或者显示目录或者复制的文件。Rsync默认监听TCP 873端口,通过过远程shell如rsh和ssh复制文件。Rsync必须在远程和本地系统上都安装。
|
||||
|
||||
rsync的主要好处是:
|
||||
|
||||
**速度**:最初会咋本地和远程之间拷贝所有内容。下次,只会传输发生改变的块或者字节。
|
||||
|
||||
**安全**:传输通过ssh协议加密数据。
|
||||
|
||||
**低带宽**:rsync在两端压缩和解压数块。
|
||||
|
||||
语法:
|
||||
#rsysnc [options] source path destination path
|
||||
|
||||
### 示例: 1 - 启用压缩 ###
|
||||
|
||||
[root@localhost /]# rsync -zvr /home/aloft/ /backuphomedir
|
||||
building file list ... done
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
sent 472 bytes received 86 bytes 1116.00 bytes/sec
|
||||
total size is 324 speedup is 0.58
|
||||
|
||||
上面的rsync命令使用了-z来启用压缩,-v是可视化,-r是递归。上面在本地的/home/aloft/和/backuphomedir之间同步。
|
||||
|
||||
### 示例: 2 - 保留文件按/文件夹属性 ###
|
||||
|
||||
[root@localhost /]# rsync -azvr /home/aloft/ /backuphomedir
|
||||
building file list ... done
|
||||
./
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
|
||||
sent 514 bytes received 92 bytes 1212.00 bytes/sec
|
||||
total size is 324 speedup is 0.53
|
||||
|
||||
上面我们使用了-a选项,它保留了所有人和所属组,时间戳、软链接、权限、递归模式。
|
||||
|
||||
### 示例: 3 - 同步本地到远程主机 ###
|
||||
|
||||
root@localhost /]# rsync -avz /home/aloft/ azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/
|
||||
Password:
|
||||
|
||||
building file list ... done
|
||||
./
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
sent 514 bytes received 92 bytes 1212.00 bytes/sec
|
||||
total size is 324 speedup is 0.53
|
||||
|
||||
上面的命令允许你在本地和远程机器之间同步。你可以看到,在同步文件到另一个系统时提示你输入密码。在做远程同步时,你需要指定远程系统的用户名和IP或者主机名。
|
||||
|
||||
### 示例: 4 - 远程同步到本地 ###
|
||||
|
||||
[root@localhost /]# rsync -avz azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/ /home/aloft/
|
||||
Password:
|
||||
building file list ... done
|
||||
./
|
||||
.bash_logout
|
||||
.bash_profile
|
||||
.bashrc
|
||||
sent 514 bytes received 92 bytes 1212.00 bytes/sec
|
||||
total size is 324 speedup is 0.53
|
||||
|
||||
上面的命令同步远程文件到本地。
|
||||
|
||||
### 示例: 5 - 找出文件间的不同 ###
|
||||
|
||||
[root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/
|
||||
building file list ... done
|
||||
cd+++++++ backuphomedir/
|
||||
>f+++++++ backuphomedir/.bash_logout
|
||||
>f+++++++ backuphomedir/.bash_profile
|
||||
>f+++++++ backuphomedir/.bashrc
|
||||
>f+++++++ backuphomedir/abc
|
||||
>f+++++++ backuphomedir/xyz
|
||||
|
||||
sent 650 bytes received 136 bytes 1572.00 bytes/sec
|
||||
total size is 324 speedup is 0.41
|
||||
|
||||
上面的命令帮助你找出源地址和目标地址之间文件或者目录的不同。
|
||||
|
||||
### 示例: 6 - 备份 ###
|
||||
|
||||
rsync命令可以用来备份linux
|
||||
|
||||
你可以在cron中使用rsync安排备份。
|
||||
|
||||
0 0 * * * /usr/local/sbin/bkpscript &> /dev/null
|
||||
|
||||
----------
|
||||
|
||||
vi /usr/local/sbin/bkpscript
|
||||
|
||||
rsync -avz -e ‘ssh -p2093′ /home/test/ root@192.168.1.150:/oracle/data/
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/how-tos/rsync-copy/
|
||||
|
||||
作者:[Bobbin Zachariah][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/bobbin/
|
Loading…
Reference in New Issue
Block a user