added pid to backup file name to avoid collisions

This commit is contained in:
Brian Coca 2016-07-29 23:03:34 -04:00
parent 36bf1e6b7e
commit 123d54e736

View file

@ -1820,7 +1820,7 @@ class AnsibleModule(object):
if os.path.exists(fn):
# backups named basename-YYYY-MM-DD@HH:MM:SS~
ext = time.strftime("%Y-%m-%d@%H:%M:%S~", time.localtime(time.time()))
backupdest = '%s.%s' % (fn, ext)
backupdest = '%s.%s.%s' % (fn, os.getpid(), ext)
try:
shutil.copy2(fn, backupdest)