Initial implementation of Google Workspace backup.

This is a WIP and still needs the restore part implemented.

Not all resources are fully tested but basic elements work.
This commit is contained in:
Kenneth Skovhede
2026-02-04 15:44:23 +01:00
parent 1b1719e924
commit da246874ec
69 changed files with 3803 additions and 3 deletions
@@ -0,0 +1,42 @@
// Copyright (c) 2026 Duplicati Inc. All rights reserved.
using Duplicati.Library.Common.IO;
using Duplicati.Library.Interface;
using Google.Apis.Keep.v1.Data;
using System.Runtime.CompilerServices;
namespace Duplicati.Proprietary.GoogleWorkspace.SourceItems;
internal class KeepNoteSourceEntry(SourceProvider provider, string parentPath, Note note)
: MetaEntryBase(Util.AppendDirSeparator(SystemIO.IO_OS.PathCombine(parentPath, note.Title ?? note.Name)),
note.CreateTimeDateTimeOffset.HasValue ? note.CreateTimeDateTimeOffset.Value.UtcDateTime : DateTime.UnixEpoch,
note.UpdateTimeDateTimeOffset.HasValue ? note.UpdateTimeDateTimeOffset.Value.UtcDateTime : DateTime.UnixEpoch)
{
public override async IAsyncEnumerable<ISourceProviderEntry> Enumerate([EnumeratorCancellation] CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) yield break;
yield return new KeepNoteFileSourceEntry(this.Path, note);
if (note.Attachments != null)
{
foreach (var attachment in note.Attachments)
{
if (cancellationToken.IsCancellationRequested) yield break;
yield return new KeepNoteAttachmentSourceEntry(provider, this.Path, attachment);
}
}
}
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
{
return Task.FromResult(new Dictionary<string, string?>
{
{ "gsuite:v", "1" },
{ "gsuite:Type", SourceItemType.KeepNote.ToString() },
{ "gsuite:Name", note.Title ?? note.Name },
{ "gsuite:id", note.Name }
}
.Where(kv => !string.IsNullOrEmpty(kv.Value))
.ToDictionary(kv => kv.Key, kv => kv.Value));
}
}