|
|
@ -1297,6 +1297,9 @@ class AnsibleModule(object):
|
|
|
|
|
|
|
|
|
|
|
|
def backup_local(self, fn):
|
|
|
|
def backup_local(self, fn):
|
|
|
|
'''make a date-marked backup of the specified file, return True or False on success or failure'''
|
|
|
|
'''make a date-marked backup of the specified file, return True or False on success or failure'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backupdest = ''
|
|
|
|
|
|
|
|
if os.path.exists(fn):
|
|
|
|
# backups named basename-YYYY-MM-DD@HH:MM:SS~
|
|
|
|
# backups named basename-YYYY-MM-DD@HH:MM:SS~
|
|
|
|
ext = time.strftime("%Y-%m-%d@%H:%M:%S~", time.localtime(time.time()))
|
|
|
|
ext = time.strftime("%Y-%m-%d@%H:%M:%S~", time.localtime(time.time()))
|
|
|
|
backupdest = '%s.%s' % (fn, ext)
|
|
|
|
backupdest = '%s.%s' % (fn, ext)
|
|
|
@ -1305,6 +1308,7 @@ class AnsibleModule(object):
|
|
|
|
shutil.copy2(fn, backupdest)
|
|
|
|
shutil.copy2(fn, backupdest)
|
|
|
|
except (shutil.Error, IOError), e:
|
|
|
|
except (shutil.Error, IOError), e:
|
|
|
|
self.fail_json(msg='Could not make backup of %s to %s: %s' % (fn, backupdest, e))
|
|
|
|
self.fail_json(msg='Could not make backup of %s to %s: %s' % (fn, backupdest, e))
|
|
|
|
|
|
|
|
|
|
|
|
return backupdest
|
|
|
|
return backupdest
|
|
|
|
|
|
|
|
|
|
|
|
def cleanup(self, tmpfile):
|
|
|
|
def cleanup(self, tmpfile):
|
|
|
|