def backup_metadata(filename):
    user_folder = user_data.get_user_folder_name()
    if (not user_folder):
        flash('User folder not found', 'error')
        return
    backup_path = os.path.join(user_folder, 'backups')
    try:
        os.mkdir(backup_path)
    except FileExistsError:
        pass
    timestamp = ((datetime.now().date().strftime('%Y_%m_%d') + '_') + datetime.now().time().strftime('%H_%M_%S'))
    backup_filename = f'{user_folder}/backups/{filename}.json.{timestamp}'
    filename = f'{user_folder}/{filename}.json'
    try:
        copyfile(filename, backup_filename)
    except:
        flash(f'Error backing up file {filename}.json', 'error')
def backup_metadata(filename):
    user_folder = user_data.get_user_folder_name()
    if (not user_folder):
        flash('User folder not found', 'error')
        return
    backup_path = os.path.join(user_folder, 'backups')
    try:
        os.mkdir(backup_path)
    except FileExistsError:
        pass
    timestamp = ((datetime.now().date().strftime('%Y_%m_%d') + '_') + datetime.now().time().strftime('%H_%M_%S'))
    backup_filename = f'{user_folder}/backups/{filename}.json.{timestamp}'
    filename = f'{user_folder}/{filename}.json'
    try:
        copyfile(filename, backup_filename)
    except:
        flash(f'Error backing up file {filename}.json', 'error')