Skip to content

Commit 14aff1b

Browse files
committed
Update README with all features, commands, and usage docs
1 parent a4e18fd commit 14aff1b

File tree

1 file changed

+90
-57
lines changed

1 file changed

+90
-57
lines changed

README.md

Lines changed: 90 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@ A single Go binary that wraps [restic](https://restic.net/) for reliable, automa
44

55
Built for backing up financial documents and other critical files where reliability matters more than anything else.
66

7+
## Quick Start
8+
9+
```powershell
10+
# 1. Download restic-sentry.exe from the latest release
11+
# https://github.com/8ff/restic-sentry/releases/latest
12+
13+
# 2. Install restic (downloads latest to C:\restic\restic.exe)
14+
restic-sentry.exe install-restic
15+
16+
# 3. Generate config file
17+
restic-sentry.exe init-config
18+
19+
# 4. Edit restic-sentry.json with your S3 credentials, backup paths, and Slack webhook
20+
21+
# 5. Run a test backup
22+
restic-sentry.exe backup
23+
24+
# 6. Schedule automatic backups (run as Administrator)
25+
restic-sentry.exe install
26+
```
27+
28+
That's it. Backups will run every 6 hours (configurable), and you'll get Slack notifications on success or failure.
29+
30+
## Commands
31+
32+
| Command | Description |
33+
|---------|-------------|
34+
| `backup` | Run the full backup pipeline (preflight, unlock, init, backup, verify, prune, notify) |
35+
| `check` | Run a full integrity check — reads and verifies all stored data |
36+
| `status` | Show repository snapshots, stats, and scheduler status |
37+
| `install` | Register in Windows Task Scheduler (requires Administrator) |
38+
| `uninstall` | Remove from Windows Task Scheduler |
39+
| `install-restic` | Download and install latest restic to `C:\restic\restic.exe` |
40+
| `update` | Self-update restic-sentry to the latest release |
41+
| `init-config` | Generate an example config file |
42+
| `version` | Print version |
43+
44+
Commands that interact with the backup repository (`backup`, `check`, `status`, `install`, `uninstall`) require a config file via `--config <path>` (defaults to `restic-sentry.json` next to the binary).
45+
746
## Features
847

948
### Backup Pipeline
@@ -25,84 +64,63 @@ Every `backup` run executes a full 6-step pipeline:
2564
- **Process lock file** — prevents overlapping runs when the scheduler fires while a backup is still in progress. The lock is PID-aware: if the holding process is dead, the lock is automatically cleared. A 6-hour max age acts as a safety net so backups never get permanently stuck
2665
- **Stale restic lock cleanup** — runs `restic unlock` before every backup to clear repository locks left by crashed/killed restic processes
2766

28-
### Notifications
67+
### Slack Notifications
2968

30-
Slack webhook notifications with color-coded severity:
69+
Color-coded by severity:
3170

3271
- **Green** — backup successful, shows duration, files processed, data added
3372
- **Orange** — backup completed with warnings (some files were skipped due to permissions/locks)
3473
- **Red** — backup failed, preflight failed, or integrity check failed
3574

36-
### Observability
75+
### Copy-Pasteable Commands
3776

38-
Every restic command is logged to stderr with the full copy-pasteable command, including env vars (credentials masked with `***`):
77+
Every restic command is logged to stderr with the full command including env vars (credentials masked with `***`):
3978

4079
```
4180
RESTIC_REPOSITORY=s3:s3.us-east-1.amazonaws.com/my-backups RESTIC_PASSWORD=*** AWS_ACCESS_KEY_ID=*** AWS_SECRET_ACCESS_KEY=*** AWS_DEFAULT_REGION=us-east-1 restic backup --verbose --use-fs-snapshot --exclude *.tmp "C:\Users\Me\Documents\Financial"
4281
```
4382

44-
You can grab any logged command, fill in your real credentials, and run it manually.
45-
46-
### Scheduling
47-
48-
Self-registers in Windows Task Scheduler via `schtasks.exe`. Runs with `HIGHEST` privileges (required for VSS). Configurable interval (default: every 6 hours).
49-
50-
## Commands
51-
52-
| Command | Description |
53-
|---------|-------------|
54-
| `backup` | Run the full 6-step backup pipeline |
55-
| `check` | Run a full integrity check (`--read-data-subset=100%`) |
56-
| `status` | Show repository snapshots, stats, and scheduler status |
57-
| `install` | Register in Windows Task Scheduler |
58-
| `uninstall` | Remove from Windows Task Scheduler |
59-
| `init-config` | Generate an example config file |
60-
| `version` | Print version |
61-
62-
All commands except `init-config` and `version` accept `--config <path>` (defaults to `restic-sentry.json` next to the binary).
63-
64-
## Quick Start
83+
Grab any logged command, fill in your real credentials, and run it manually for debugging.
6584

66-
### 1. Build
85+
### Self-Update
6786

68-
```bash
69-
# From source (cross-compile for Windows from any OS)
70-
make build-windows # produces restic-sentry.exe
71-
72-
# Or just for your current platform
73-
make build
87+
```powershell
88+
restic-sentry.exe update
7489
```
7590

76-
### 2. Configure
91+
Checks the latest release on GitHub, downloads the new binary, and replaces itself. The old binary is kept as `restic-sentry.exe.old` as a safety net. If the update fails mid-write, it rolls back automatically.
7792

78-
```powershell
79-
# Generate example config
80-
restic-sentry.exe init-config
93+
### Restic Installer
8194

82-
# Edit restic-sentry.json with your values
95+
```powershell
96+
restic-sentry.exe install-restic
8397
```
8498

85-
### 3. Test
99+
Downloads the latest restic release from GitHub, extracts `restic.exe` to `C:\restic\restic.exe`. The default config already points to this path, so no extra configuration needed.
100+
101+
### Scheduling
86102

87103
```powershell
88-
# Run a backup manually to make sure everything works
89-
restic-sentry.exe backup --config restic-sentry.json
104+
# Run as Administrator
105+
restic-sentry.exe install
90106
```
91107

92-
### 4. Schedule
108+
Registers itself in Windows Task Scheduler via `schtasks.exe`. Runs with `HIGHEST` privileges (required for VSS). Default interval is every 6 hours, configurable via `schedule_interval_hours` in the config.
93109

94110
```powershell
95-
# Run as Administrator — registers in Task Scheduler
96-
restic-sentry.exe install --config restic-sentry.json
111+
# Remove the scheduled task
112+
restic-sentry.exe uninstall
97113
```
98114

99115
## Configuration
100116

117+
Generated by `restic-sentry.exe init-config`:
118+
101119
```jsonc
102120
{
103121
// S3 backend
104122
"s3": {
105-
"endpoint": "", // custom S3 endpoint (leave empty for AWS)
123+
"endpoint": "", // custom S3 endpoint (leave empty for AWS)
106124
"bucket": "my-backups",
107125
"access_key": "AKIA...",
108126
"secret_key": "...",
@@ -112,8 +130,8 @@ restic-sentry.exe install --config restic-sentry.json
112130
// Restic repo encryption password
113131
"restic_password": "...",
114132

115-
// Path to restic binary (default: "restic", i.e. on PATH)
116-
"restic_binary": "",
133+
// Path to restic binary (default: C:\restic\restic.exe)
134+
"restic_binary": "C:\\restic\\restic.exe",
117135

118136
// Directories to back up
119137
"paths": [
@@ -124,19 +142,19 @@ restic-sentry.exe install --config restic-sentry.json
124142
"excludes": ["*.tmp", "~$*"],
125143

126144
// Slack webhook URL
127-
"slack_webhook_url": "https://hooks.slack.com/services/T.../B.../...",
145+
"slack_webhook_url": "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK",
128146

129147
// How often to run (hours) — used by 'install' command
130148
"schedule_interval_hours": 6,
131149

132150
// Retry on transient failures
133151
"retry": {
134-
"max_attempts": 3, // number of attempts
135-
"base_delay_sec": 30 // delay doubles each retry: 30s, 60s, 120s
152+
"max_attempts": 3, // number of attempts
153+
"base_delay_sec": 30 // delay doubles each retry: 30s, 60s, 120s
136154
},
137155

138156
// Retention policy
139-
"keep_last": 0, // 0 = disabled
157+
"keep_last": 0, // 0 = disabled
140158
"keep_daily": 7,
141159
"keep_weekly": 4,
142160
"keep_monthly": 12,
@@ -146,6 +164,25 @@ restic-sentry.exe install --config restic-sentry.json
146164
}
147165
```
148166

167+
### Configuration Notes
168+
169+
- All fields except `restic_binary`, `endpoint`, `excludes`, `keep_last`, and `retry` are required
170+
- The config file has secrets in plaintext — set file permissions accordingly (`icacls config.json /inheritance:r /grant:r "%USERNAME%:F"`)
171+
- S3 endpoint can be left empty for AWS, or set to a custom endpoint for MinIO, Backblaze B2, etc.
172+
173+
## Building from Source
174+
175+
```bash
176+
# Build for Windows (from any OS)
177+
make build-windows # produces restic-sentry.exe
178+
179+
# Build for current platform
180+
make build
181+
182+
# Run tests
183+
make test
184+
```
185+
149186
## Project Structure
150187

151188
```
@@ -160,16 +197,12 @@ internal/
160197
scheduler/scheduler.go Windows Task Scheduler via schtasks.exe
161198
slack/slack.go Webhook notifications (green/orange/red)
162199
logger/logger.go Structured JSON logging to stderr
200+
install/github.go GitHub API client for release fetching
201+
install/restic.go Restic binary downloader/installer
202+
install/selfupdate.go Self-update mechanism
163203
Makefile Build targets
164204
```
165205

166-
## Prerequisites
167-
168-
- [restic](https://restic.net/) installed and on PATH (or provide full path in config)
169-
- An S3 bucket (AWS, MinIO, Backblaze B2 with S3 compatibility, etc.)
170-
- A Slack incoming webhook URL
171-
- Windows (for VSS and Task Scheduler features; backup/check work on any OS)
172-
173206
## S3 Recommendations
174207

175208
- **Enable bucket versioning** — belt-and-suspenders against accidental deletion or repo corruption

0 commit comments

Comments
 (0)