美文网首页
4-10.5 Linux 中的文件同步传输 --- rsync

4-10.5 Linux 中的文件同步传输 --- rsync

作者: 捌千里路雲和月 | 来源:发表于2021-08-09 22:56 被阅读0次
  • 源目录有 / 和 没有 / 区别。源目录后带 / 号是指对目录下的文件进行传输,没有带 / 号是指连同目录以及目录下的文件一并传输。新建 backups_directory 目录用作储存源目录,新建 backups_file 目录储存源目录的文件。
[root@localhost test]# mkdir backups_directory    ## backups_directory 目录用作储存源目录
[root@localhost test]# 
[root@localhost test]# mkdir backups_file    ## backups_file 目录储存源目录的文件
[root@localhost test]# 
[root@localhost test]# tree    ## 查看目录结构
.
├── backups_directory
├── backups_file
└── SRC
    ├── demo1.txt
    ├── demo2.txt
    └── demo3.txt

3 directories, 3 files

## SRC 目录后没有带 / 号,是整个 SRC目录递归传输到 backups_directory 目录下
[root@localhost test]# rsync -a SRC backups_directory/    

## SRC 目录后带 / 号,是 SRC目录下的文件传输到 backups_file 目录下
[root@localhost test]# rsync -a SRC/ backups_file/
[root@localhost test]# 
[root@localhost test]# tree    ## 目录结构如下
.
├── backups_directory
│   └── SRC
│       ├── demo1.txt
│       ├── demo2.txt
│       └── demo3.txt
├── backups_file
│   ├── demo1.txt
│   ├── demo2.txt
│   └── demo3.txt
└── SRC
    ├── demo1.txt
    ├── demo2.txt
    └── demo3.txt

4 directories, 9 files
[root@localhost test]# 

相关文章

网友评论

      本文标题:4-10.5 Linux 中的文件同步传输 --- rsync

      本文链接:https://www.haomeiwen.com/subject/ugytbltx.html