ansible - Ansible `archive` 模块无需压缩即可存档
问题描述
我必须归档一堆文件,并希望避免压缩以节省时间。这是归档 1 TB 数据并将其写入不同驱动器的日常操作,因此“时间至关重要”。查看Ansible 归档模块文档,不清楚如何在不压缩的情况下构建目标文件。目前,我的 Ansible 任务如下所示:
- name: Create snapshot tarball
become: true
archive:
path: "{{ snapshots_path.stdout_lines }}"
dest: "{{backup_location}}{{short_date.stdout}}_snapshot.tgz"
owner: "{{backup_user}}"
group: "{{backup_group}}"
是否可以通过告诉模块不要压缩来加快这个过程?如果是,如何?
解决方案
另一方面,基于superuser上的其他答案,tar
默认情况下不压缩文件gz
,这是默认format
值archive
。
所以你可以尝试通过:
- name: Create snapshot tarball
become: true
archive:
path: "{{ snapshots_path.stdout_lines }}"
dest: "{{backup_location}}{{short_date.stdout}}_snapshot.tar"
format: tar
owner: "{{backup_user}}"
group: "{{backup_group}}"
这也得到了以下手册页的支持tar
:
DESCRIPTION GNU tar is an archiving program designed to store multiple files in a single file (an archive), and to manipulate such archives. The archive can be either a regular file or a device (e.g. a tape drive, hence the name of the program, which stands for tape archiver), which can be located either on the local or on a remote machine.
推荐阅读
- android - 为什么 assembleDebug 成功但 assembleRelease 在本机反应中失败?
- python - 使用 datetime.strptime 时如何不显示年月日?
- gcc - glib:unresolvable R_X86_64_NONE 重定位符号'strncmp@@GLIBC_2.2.5'
- java - 是否有可以从用户那里获取 java 语法并将其转换为输出的 java 程序,有点像迷你 IDE?
- elasticsearch - elasticsearch 是否强一致?
- javascript - 嵌套数组的索引
- android - 如何修复可空接收器的不安全使用错误?
- javascript - 将“end”设置为“false”的流在可写流完成之前解析
- android - 如何从 Firestore 文档中获取数据
- java - 如何将删除按钮 (x) 附加到动态创建的 ListView 的每个成员?