Change timestamp to modified instead of creation
This commit is contained in:
parent
cf9499a988
commit
7ff917bdcd
1 changed files with 1 additions and 1 deletions
|
|
@ -127,7 +127,7 @@ def backup_file(filename, backup_dir):
|
||||||
|
|
||||||
# Get a list of all previous backup files with the same basename as well as the creation time for the
|
# Get a list of all previous backup files with the same basename as well as the creation time for the
|
||||||
prev_backup_files = [file for file in os.listdir(backup_dir) if os.path.basename(filename.split('.')[0]) in file]
|
prev_backup_files = [file for file in os.listdir(backup_dir) if os.path.basename(filename.split('.')[0]) in file]
|
||||||
creation_time = datetime.strptime(time.ctime(os.path.getctime(filename)), '%a %b %d %H:%M:%S %Y').strftime("%Y-%m-%d_%H-%M-%S")
|
creation_time = datetime.strptime(time.ctime(os.path.getmtime(filename)), '%a %b %d %H:%M:%S %Y').strftime("%Y-%m-%d_%H-%M-%S")
|
||||||
ext = '.' + filename.split('.')[-1]
|
ext = '.' + filename.split('.')[-1]
|
||||||
|
|
||||||
dst_basename = creation_time + '_' + filename.split('.')[0] + '_' + f'{len(prev_backup_files)}'.zfill(4) + ext
|
dst_basename = creation_time + '_' + filename.split('.')[0] + '_' + f'{len(prev_backup_files)}'.zfill(4) + ext
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue