feat: make prune policy configurable in the addrepoview in the UI

This commit is contained in:
garethgeorge
2024-01-15 14:35:05 -08:00
parent ac8db31713
commit 3fd08eb8e4
5 changed files with 52 additions and 8 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ func (t *PruneTask) Next(now time.Time) *time.Time {
SnapshotId: t.linkSnapshot,
UnixTimeStartMs: timeToUnixMillis(*ret),
Status: v1.OperationStatus_STATUS_PENDING,
Op: &v1.Operation_OperationForget{},
Op: &v1.Operation_OperationPrune{},
}); err != nil {
zap.S().Errorf("task %v failed to add operation to oplog: %v", t.Name(), err)
return nil
+4 -4
View File
@@ -6,7 +6,7 @@ option go_package = "github.com/garethgeorge/backrest/gen/go/v1";
// Config is the top level config object for restic UI.
message Config {
// modification number, used for read-modify-write consistency in the UI. Incremented on every write.
// modification number, used for read-modify-write consistency in the UI. Incremented on every write.
int32 modno = 1 [json_name="modno"];
// override the hostname tagged on backups. If provided it will be used in addition to tags to group backups.
@@ -49,9 +49,9 @@ message RetentionPolicy {
}
message PrunePolicy {
int32 max_frequency_days = 1; // max frequency of prune runs in days. If 0, prune will be run on every backup.
int32 max_unused_percent = 100; // max percentage of repo size that can be unused before prune is run.
int32 max_unused_bytes = 101; // max number of bytes that can be unused before prune is run.
int32 max_frequency_days = 1 [json_name="maxFrequencyDays"]; // max frequency of prune runs in days. If 0, prune will be run on every backup.
int32 max_unused_percent = 100 [json_name="maxUnusedPercent"]; // max percentage of repo size that can be unused before prune is run.
int32 max_unused_bytes = 101 [json_name="maxUnusedBytes"]; // max number of bytes that can be unused before prune is run.
}
message User {
+2 -3
View File
@@ -1,6 +1,5 @@
#!/bin/bash
curl -s https://api.github.com/repos/restic/restic/releases/latest \
| grep "https://api.github.com/repos/restic/restic/tarball/" \
| sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+).*/\1/
| grep "https://api.github.com/repos/restic/restic/tarball/" \
| sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+).*/\1/' # extract just the version number
+12
View File
@@ -0,0 +1,12 @@
#! /bin/bash
latest_restic_version=$(./scripts/latest-restic-version.sh)
if [ -z "$latest_restic_version" ]; then
echo "Failed to get latest restic version"
exit 1
fi
echo "Latest restic version: $latest_restic_version"
sed -i -E "s/^.*RequiredResticVersion\ =\ .*$/ RequiredResticVersion\ =\ \"$latest_restic_version\"/g" internal/resticinstaller/resticinstaller.go
+33
View File
@@ -8,6 +8,8 @@ import {
Button,
Row,
Col,
Card,
InputNumber,
} from "antd";
import React, { useState } from "react";
import { useShowModal } from "../components/ModalManager";
@@ -396,6 +398,37 @@ export const AddRepoModal = ({
)}
</Form.List>
{/* Repo.prunePolicy */}
<Form.Item
required={false}
label={
<Tooltip title={<span>The schedule on which prune operations are run for this repository. Read <a href="https://restic.readthedocs.io/en/stable/060_forget.html#customize-pruning">the restic docs on customizing prune operations</a> for more details.</span>}>
Prune Policy
</Tooltip>
}
>
<Card>
<Form.Item
name={["prunePolicy", "maxFrequencyDays"]}
initialValue={template?.prunePolicy?.maxFrequencyDays || 7}
required={false}
>
<InputNumber addonBefore={<div style={{ width: "12em" }}>Max Frequency Days</div>} />
</Form.Item>
<Form.Item
name={["prunePolicy", "maxUnusedPercent"]}
initialValue={template?.prunePolicy?.maxUnusedPercent || 25}
required={false}
>
<InputNumber addonBefore={
<Tooltip title="The maximum percentage of the repo size that may be unused after a prune operation completes. High values reduce copying at the expense of storage.">
<div style={{ width: "12em" }}>Max Unused Percent</div>
</Tooltip>}
/>
</Form.Item>
</Card>
</Form.Item>
<Form.Item shouldUpdate label="Preview">
{() => (
<Typography>