Skip to content

Commit

Permalink
feat: add case insensitive excludes (iexcludes) (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge authored Feb 20, 2024
1 parent c1ee33f commit bf6fb7e
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 102 deletions.
214 changes: 112 additions & 102 deletions gen/go/v1/config.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions internal/orchestrator/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (r *RepoOrchestrator) Backup(ctx context.Context, plan *v1.Plan, progressCa
var opts []restic.BackupOption
opts = append(opts, restic.WithBackupPaths(plan.Paths...))
opts = append(opts, restic.WithBackupExcludes(plan.Excludes...))
opts = append(opts, restic.WithBackupIExcludes(plan.Iexcludes...))
opts = append(opts, restic.WithBackupTags(tagForPlan(plan)))

if len(snapshots) > 0 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/restic/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ func WithBackupExcludes(excludes ...string) BackupOption {
}
}

func WithBackupIExcludes(iexcludes ...string) BackupOption {
return func(opts *BackupOpts) {
for _, iexclude := range iexcludes {
opts.extraArgs = append(opts.extraArgs, "--iexclude", iexclude)
}
}
}

func WithBackupTags(tags ...string) BackupOption {
return func(opts *BackupOpts) {
for _, tag := range tags {
Expand Down
1 change: 1 addition & 0 deletions proto/v1/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ message Plan {
string repo = 2 [json_name="repo"]; // ID of the repo to use.
repeated string paths = 4 [json_name="paths"]; // paths to include in the backup.
repeated string excludes = 5 [json_name="excludes"]; // glob patterns to exclude.
repeated string iexcludes = 9 [json_name="iexcludes"]; // case insensitive glob patterns to exclude.
string cron = 6 [json_name="cron"]; // cron expression describing the backup schedule.
RetentionPolicy retention = 7 [json_name="retention"]; // retention policy for snapshots.
repeated Hook hooks = 8 [json_name="hooks"]; // hooks to run on events for this plan.
Expand Down
8 changes: 8 additions & 0 deletions webui/gen/ts/v1/config_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ export class Plan extends Message<Plan> {
*/
excludes: string[] = [];

/**
* case insensitive glob patterns to exclude.
*
* @generated from field: repeated string iexcludes = 9;
*/
iexcludes: string[] = [];

/**
* cron expression describing the backup schedule.
*
Expand Down Expand Up @@ -233,6 +240,7 @@ export class Plan extends Message<Plan> {
{ no: 2, name: "repo", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "paths", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 5, name: "excludes", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 9, name: "iexcludes", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 6, name: "cron", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 7, name: "retention", kind: "message", T: RetentionPolicy },
{ no: 8, name: "hooks", kind: "message", T: Hook, repeated: true },
Expand Down
55 changes: 55 additions & 0 deletions webui/src/views/AddPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export const AddPlanModal = ({
)}
</Form.List>
</Form.Item>

{/* Plan.excludes */}
<Form.Item label="Excludes" required={false}>
<Form.List
Expand Down Expand Up @@ -313,6 +314,60 @@ export const AddPlanModal = ({
</Form.List>
</Form.Item>

{/* Plan.excludes */}
<Form.Item label="Excludes (Case Insensitive)" required={false}>
<Form.List
name="iexcludes"
rules={[]}
initialValue={template ? template.iexcludes : []}
>
{(fields, { add, remove }, { errors }) => (
<>
{fields.map((field, index) => (
<Form.Item
required={false}
key={field.key}
>
<Form.Item
{...field}
validateTrigger={["onChange", "onBlur"]}
initialValue={""}
rules={[
{
required: true,
},
]}
noStyle
>
<URIAutocomplete
style={{ width: "90%" }}
onBlur={() => form.validateFields()}
globAllowed={true}
/>
</Form.Item>
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
style={{ paddingLeft: "5px" }}
/>
</Form.Item>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => add()}
style={{ width: "90%" }}
icon={<PlusOutlined />}
>
Add Case Insensitive Exclusion Glob
</Button>
<Form.ErrorList errors={errors} />
</Form.Item>
</>
)}
</Form.List>
</Form.Item>

{/* Plan.cron */}
<Tooltip title="Cron expression to schedule the plan in 24 hour time">
<Form.Item<Plan>
Expand Down

0 comments on commit bf6fb7e

Please sign in to comment.