import win32evtlog

def read_backup_logs():
    log_type = 'Application'  # Ereignisprotokolltyp (z. B. 'Application', 'System', etc.)
    log_source = 'Microsoft-Windows-Backup'  # Quelle des Ereignisprotokolls für die Sicherung

    handle = win32evtlog.OpenEventLog(None, log_type)
    flags = win32evtlog.EVENTLOG_BACKWARDS_READ | win32evtlog.EVENTLOG_SEQUENTIAL_READ
    events = win32evtlog.ReadEventLog(handle, flags, 0)

    backup_events = []

    for event in events:
        if event.SourceName == log_source:
            backup_events.append({
                'TimeGenerated': event.TimeGenerated.Format(),
                'Message': event.StringInserts[0]
            })

    win32evtlog.CloseEventLog(handle)

    return backup_events

if __name__ == "__main__":
    backup_logs = read_backup_logs()
    for event in backup_logs:
        print(f"Time: {event['TimeGenerated']}\nMessage: {event['Message']}\n")
