恢复使用 Copy 创建的备份文件 [英] restore backup file created with Copy
本文介绍了恢复使用 Copy 创建的备份文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果备份文件是使用复制(使用备份=是)创建的,例如,使用此任务:
If a backup file is created using Copy (with backup=yes), for example, with this task:
- name: copy file
copy:
dest: path/to/dest
src: path/to/src
backup: yes
如果文件 path/to/dest
已经存在,它将被移动到一个类似于 path/to/dest.12345.2006-07-08@09:10:11 的文件中
If the file path/to/dest
already exists, it will be moved in a file looking like path/to/dest.12345.2006-07-08@09:10:11
有没有办法恢复它,或者获取备份文件的文件名以便恢复它?
Is there a way to restore it, or to get the filename of the backup file in order to restore it ?
推荐答案
备份文件的绝对文件名(如果生成,那么如果changed"为真),在输出对象中返回,所以(取以下为伪代码,因为我没有测试它):
The absolute file name of the backup file (if generated, so if "changed" is true), is returned in the output object, so (take the following as pseudocode as I am not testing it):
- name: copy file
copy:
dest: path/to/dest
src: path/to/src
backup: yes
register: copy_file
- debug: var=copy_file.backup_file
- name: restore backup
copy:
dest: path/to/dest
src: copy_file.backup_file
remote_src: true
when: copy_file.changed and some condition of yours
这篇关于恢复使用 Copy 创建的备份文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文