- rsync -b 备份文件的时候会将旧文件默认加上 ~ 符号,标识为一个备份文件。--suffix 可以修改这个标识符。
- 4-10.11 内容:
通过 rsync -bv --suffix 学习修改备份标识符。
- 例:首先创建一个备份目录 backups_suffix,源目录延用上一节 4-10.10 的 SRC。
[root@localhost test]# mkdir backups_suffix ## 创建备份目录 backups_suffix
[root@localhost test]#
[root@localhost test]# tree
.
├── backups_suffix ## 备份目录
├── include-file.txt
└── SRC
├── directory
│ ├── directory4
│ │ └── demo4.txt
│ ├── directory5
│ │ └── demo5.txt
│ └── file2.txt
├── directory1
│ └── demo1.txt
├── directory2
│ └── demo2.txt
├── directory3
│ └── demo3.txt
├── file1.txt
├── file3.txt
├── file4.txt
└── office_directory
├── docxfile.docx
├── elsxfile.elsx
└── pptxfile.pptx
9 directories, 13 files
- -b --suffix 指定文件后缀测试。
- 第一次不用 --suffix,只用 -b 备份 SRC 目录下的 file1.txt 文件到 backups_suffix 目录。第一个文件不会有任何标识。
[root@localhost test]# rsync -bv SRC/file1.txt backups_suffix/
file1.txt
sent 83 bytes received 35 bytes 236.00 bytes/sec
total size is 0 speedup is 0.00
[root@localhost test]#
[root@localhost test]# ll backups_suffix/
total 0
-rw-r--r--. 1 root root 0 Sep 2 14:46 file1.txt ## 14:46 第一个备份文件
[root@localhost test]#
- 第二次也只用 -b 备份 SRC 目录下的 file1.txt 文件到 backups_suffix 目录。第一个 14:46 文件默认 ~ 符号作标识,新的 14:47 文件不会有标识。
[root@localhost test]#
[root@localhost test]# rsync -bv SRC/file1.txt backups_suffix/
file1.txt
sent 83 bytes received 35 bytes 236.00 bytes/sec
total size is 0 speedup is 0.00
[root@localhost test]#
[root@localhost test]# ll backups_suffix/
total 0
-rw-r--r--. 1 root root 0 Sep 2 14:47 file1.txt ## 14:47 新的备份文件
-rw-r--r--. 1 root root 0 Sep 2 14:46 file1.txt~ ## 14:46 备份文件用 ~ 标识
[root@localhost test]#
- 第三次用 --suffix=.bak 备份 SRC 目录下的 file1.txt 文件到 backups_suffix 目录,指定备份后缀为 .bak。第一个 14:46 文件默认 ~ 符号作标识,14:47 的文件用 .bak 作标识。新的 14:48 文件不会有标识。
[root@localhost test]#
[root@localhost test]# rsync -bv --suffix=.bak SRC/file1.txt backups_suffix/
file1.txt
sent 83 bytes received 35 bytes 236.00 bytes/sec
total size is 0 speedup is 0.00
[root@localhost test]#
[root@localhost test]# ll backups_suffix/
total 0
-rw-r--r--. 1 root root 0 Sep 2 14:48 file1.txt ## 14:48 新的备份文件
-rw-r--r--. 1 root root 0 Sep 2 14:46 file1.txt~ ## 14:46 备份文件用 ~ 标识
-rw-r--r--. 1 root root 0 Sep 2 14:47 file1.txt.bak ## 14:47 备份文件用 .bak 标识
[root@localhost test]#
- 第四次用 --suffix=.bak1 备份 SRC 目录下的 file1.txt 文件到 backups_suffix 目录,指定备份后缀为 .bak1。第一个 14:46 文件默认 ~ 符号作标识,14:47 的文件用 .bak 作标识。 14:48 文件用 .bak1 作标识。新的 14:49 文件不会有标识。
[root@localhost test]#
[root@localhost test]# rsync -bv --suffix=.bak1 SRC/file1.txt backups_suffix/
file1.txt
sent 83 bytes received 35 bytes 236.00 bytes/sec
total size is 0 speedup is 0.00
[root@localhost test]#
[root@localhost test]# ll backups_suffix/
total 0
-rw-r--r--. 1 root root 0 Sep 2 14:49 file1.txt ## 14:49 新的备份文件
-rw-r--r--. 1 root root 0 Sep 2 14:46 file1.txt~ ## 14:46 备份文件用 ~ 标识
-rw-r--r--. 1 root root 0 Sep 2 14:47 file1.txt.bak ## 14:47 备份文件用 .bak 标识
-rw-r--r--. 1 root root 0 Sep 2 14:48 file1.txt.bak1 ## 14:48 备份文件用 .bak1 标识
[root@localhost test]#
- 通过测试最新的的备份文件不会有标识符,没有用 -- suffix 指定后缀的则用默认的 ~ 符号作标识。如果用 -- suffix 指定后缀则上一次的备份文件添加新的后缀作标识符。
网友评论