Skip to content

Commit

Permalink
fix: UI quality of life improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Aug 27, 2024
1 parent af09e47 commit cc173aa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 42 deletions.
2 changes: 0 additions & 2 deletions docs/content/1.introduction/1.getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ Username and password
* If you don't want to use authentication (e.g. a local only installation or if you're using an authenticating reverse proxy) you can disabled authentication.


#### Backrest Host Name

#### Add a new repository

A Backrest repository is implemented as a restic repository under-the-hood (more on this later). A Repo is a configuration object which identifies a storage location and the credentials that will be used to encrypt snapshots sent to that storage. You can either add an existing repo that you created on the restic CLI or create a new one in the Backrest UI. In either case, click the "Add Repo" button in the UI to configure Backrest to use your backup location.
Expand Down
3 changes: 2 additions & 1 deletion internal/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ func (o *Orchestrator) Run(ctx context.Context) {

// Clone the operation incase we need to reset changes and reschedule the task for a retry
originalOp := proto.Clone(t.Op).(*v1.Operation)
if t.Op != nil {
if t.Op != nil && t.retryCount != 0 {
t.Op.DisplayMessage = fmt.Sprintf("running after %d retries", t.retryCount)
// Delete any previous hook executions for this operation incase this is a retry.
prevHookExecutionIDs := []int64{}
if err := o.OpLog.Query(oplog.Query{FlowID: t.Op.FlowId}, func(op *v1.Operation) error {
Expand Down
48 changes: 13 additions & 35 deletions webui/src/components/HooksFormList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,22 @@ export interface HookFields {

export const hooksListTooltipText = (
<>
Hooks are actions that can execute on backup lifecycle events. Available
events are:
<ul>
<li>On Finish Snapshot: Runs after a snapshot is finished.</li>
<li>On Start Snapshot: Runs when a snapshot is started.</li>
<li>On Snapshot Error: Runs when a snapshot fails.</li>
<li>On Any Error: Runs when any error occurs.</li>
</ul>
Arguments are available to hooks as{" "}
Hooks let you configure actions e.g. notifications and scripts that run in
response to the backup lifecycle. See{" "}
<a
href="https://garethgeorge.github.io/backrest/docs/hooks"
target="_blank"
rel="noopener noreferrer"
href="https://pkg.go.dev/text/template"
>
Go template variables
the hook documentation
</a>{" "}
for available options, or
<a
href="https://garethgeorge.github.io/backrest/cookbooks/command-hook-examples"
target="_blank"
>
the cookbook
</a>
<ul>
<li>.Task - the name of the task that triggered the hook.</li>
<li>.Event - the event that triggered the hook.</li>
<li>.Repo - the name of the repo the event applies to.</li>
<li>.Plan - the name of the plan the event applies to.</li>
<li>.Error - the error if any is available.</li>
<li>.CurTime - the time of the event.</li>
<li>
.SnapshotId - the restic snapshot structure if this is finish snapshot
operation and it completed successfully.
</li>
</ul>
Functions
<ul>
<li>.ShellEscape - escapes a string to be used in a shell command.</li>
<li>.JsonMarshal - serializes a value to be used in a json string.</li>
<li>.Summary - prints a formatted summary of the event.</li>
<li>.FormatTime - prints time formatted as RFC3339.</li>
<li>.FormatSizeBytes - prints a formatted size in bytes.</li>
</ul>
for scripting examples.
</>
);

Expand Down Expand Up @@ -197,9 +177,7 @@ const hookTypes: {
component: ({ field }: { field: FormListFieldData }) => {
return (
<>
<Tooltip title="Script to execute. Commands will not work in the docker build of Backrest.">
Script:
</Tooltip>
<Tooltip title="Script to execute.">Script:</Tooltip>
<Form.Item
name={[field.name, "actionCommand", "command"]}
rules={[requiredField("command is required")]}
Expand Down
2 changes: 1 addition & 1 deletion webui/src/components/OperationTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ const BackupView = ({ backup }: { backup?: FlowDisplayInfo }) => {
height: "60px",
}}
>
<h3>Backup on {formatTime(backup.displayTime)}</h3>
<h3>{formatTime(backup.displayTime)}</h3>
<div style={{ position: "absolute", right: "20px" }}>
{backup.status !== OperationStatus.STATUS_PENDING &&
backup.status !== OperationStatus.STATUS_INPROGRESS
Expand Down
4 changes: 2 additions & 2 deletions webui/src/components/ScheduleFormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const ScheduleDefaultsInfrequent: ScheduleDefaults = {
maxFrequencyHours: 30 * 24,
// midnight on the first day of the month
cron: "0 0 1 * *",
cronDropdowns: ["period", "months", "month-days"],
cronPeriods: ["month"],
cronDropdowns: ["period", "months", "month-days", "week-days", "hours"],
cronPeriods: ["month", "week"],
};

export const ScheduleDefaultsDaily: ScheduleDefaults = {
Expand Down
2 changes: 1 addition & 1 deletion webui/src/lib/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
export const formatBytes = (bytes?: number | string) => {
if (!bytes) {
return "0B";
Expand All @@ -6,7 +7,6 @@ export const formatBytes = (bytes?: number | string) => {
bytes = parseInt(bytes);
}

const units = ["B", "KB", "MB", "GB", "TB", "PB"];
let unit = 0;
while (bytes > 1024) {
bytes /= 1024;
Expand Down

0 comments on commit cc173aa

Please sign in to comment.