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

How to use rsync under Linux

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to use rsync under Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Rsync is a commonly used Linux application for file synchronization, which can synchronize files between a local computer and a remote computer, or between two local directories (but does not support synchronization between two remote computers). It can also be used as a file copy tool to replace the cp and mv commands.

Syntax: # rsysnc [options] source path destination path example: 1-enable compression [root@localhost /] # rsync-zvr / home/aloft/ / backuphomedirbuilding file list... Donebash_logoutbash_profilebashrcsent 472 bytes received 86 bytes 1116.00 bytes/sectotal size is 324 speedup is 0.58

The above rsync command uses-z to enable compression,-v is visual, and-r is recursive. The above synchronizes between the local / home/aloft/ and / backuphomedir.

Example: 2-preserve the properties of files and folders [root@localhost /] # rsync-azvr / home/aloft/ / backuphomedirbuilding file list. Done/bash_logoutbash_profilebashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53

Above we used the-an option, which retains everyone and their groups, timestamps, soft links, permissions, and runs in 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_logoutbash_profilebashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53

The above command allows you to synchronize between local and remote machines. You can see that you are prompted for a password when synchronizing files to another system. When doing remote synchronization, you need to specify the user name and IP or hostname of the remote system.

Example: 4-remote sync to local [root@localhost /] # rsync-avz azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/ / home/aloft/Password:building file list... Done/bash_logoutbash_profilebashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53

The above command synchronizes remote files locally.

Example: 5-find out the differences between files [root@localhost backuphomedir] # rsync-avzi / backuphomedir / home/aloft/building file list. Donecd+ backuphomedir/ > f + backuphomedir/.bash_logout > f + backuphomedir/.bash_profile > f + backuphomedir/.bashrc > f + backuphomedir/abc > f + backuphomedir/xyzsent 650 bytes received 136 bytes 1572.00 bytes/sectotal size is 324 speedup is 0.41 example: 6-backup

The rsync command can be used to back up linux.

You can use rsync in cron to schedule backups.

00 * / usr/local/sbin/bkpscript & > / dev/nullvi / usr/local/sbin/bkpscriptrsync-avz-e'ssh-p2093' / home/test/ root@192.168.1.150:/oracle/data/ this is the end of the article on "how to use rsync under Linux". I hope the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good. Please share it for more people to see.

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

Development

Wechat

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

12
Report