Commit graph

139 commits

Author SHA1 Message Date
Jakub Trávník
60c0778b74 refactor: improve config import logging, add CLI JSON output and idempotent re-runs
- Add `--json` flag for machine-readable JSON output
- Add `--log-level` flag to control logging verbosity
- Add `skipped` counter to ImportResult for idempotent operations
- Change "already exists" conditions from warnings to skipped (info logs)
- Recovery key mismatch now errors and stops import early
- Pre-check volumes and notification destinations before creation
- Attachment functions merge missing items instead of overwriting
- Add toError() and mergeResults() helpers to reduce code duplication
- Extract readConfigJson() and createOutput() for cleaner CLI code
- Move fs/path imports to top level in config-import.ts
2025-12-30 12:39:02 +01:00
Jakub Trávník
e9424e3145
Merge branch 'main' into config-import-json 2025-12-29 23:55:42 +01:00
James Brink
eded452c83
feat: parameterize PORT and MIGRATIONS_PATH environment variables (#253)
* feat: parameterize PORT and MIGRATIONS_PATH environment variables

Allow configuring the server port (default: 4096) and migrations
folder path via environment variables for flexible deployment.

* fix: address PR review feedback

- Use consistent schema syntax (string? instead of key?)
- Remove config tests per maintainer request
2025-12-29 20:59:38 +01:00
Jakub Trávník
f908883784
Fix error handling in repository existence check 2025-12-29 20:54:30 +01:00
Jakub Trávník
e5d8827fd8
Enhance error logging for repo existence check
Improve error handling in repository existence check.
2025-12-29 20:46:21 +01:00
Jakub Trávník
a71009ff78
Increment warning count on volume mount failure 2025-12-29 20:41:01 +01:00
Jakub Trávník
5a4f4641b4 feat: improve config import with result tracking and idempotent repository detection
- Add ImportResult type to track succeeded/warnings/errors counts across all import functions
- Implement multi-layer repository duplicate detection:
  - URL-based check (same path/bucket/endpoint already registered)
  - Restic repo check (path is already a restic repository)
  - Name-based fallback check
- Standardize logging between CLI and env var import methods with logImportSummary()
- CLI exits with code 1 when import has errors
- Remove shortId override for local repo migrations (use full path with isExistingRepository instead)
- Update example JSON and README:
  - Document that local repo path is optional (defaults to /var/lib/zerobyte/repositories)
  - Add existing-local-repo example with isExistingRepository: true
  - Add S3 endpoint field to example
  - Expand config behavior docs to explain all repository skip conditions
- Improve .gitignore to exclude all JSON except example template
2025-12-29 18:34:02 +01:00
Jakub Trávník
e4f66de447 linting and SFTP volume support 2025-12-29 11:16:36 +01:00
Jakub Trávník
5cdec5cdaa Merge remote-tracking branch 'origin/main' into config-import-json 2025-12-29 11:06:06 +01:00
Jakub Trávník
45b5c0d752 feat(cli): add import-config command for manual config import
Add CLI command to import configuration from file or stdin, providing
an alternative to the env-var-based automatic import on startup.

Features:
- `import-config --config <path>` to import from a mounted file
- `import-config --stdin` to import from piped input (no file mount needed)
- `import-config --dry-run` to validate config without importing

Changes:
- Add app/server/cli/commands/import-config.ts with new command
- Register importConfigCommand in CLI index
- Refactor config-import.ts: extract runImport() and add applyConfigImport()
  for direct config object import (used by CLI)
- Update docs with both import methods (env var and CLI examples)
2025-12-29 11:04:12 +01:00
Nico
c05aa8d5bf
feat: add support for SFTP volume backend (#249)
* feat: add support for SFTP volume backend

* feat: allow more secure SFTP connection with known hosts

* refactor: make default value for skip host key check to false

* refactor: use os.userInfo when setting uid/gid in mount commands
2025-12-28 18:30:49 +01:00
Nico
ae5233d9fb
refactor: tag snapshots with schedule short_id instead of db id (#248)
* refactor: tag snapshots with schedule short_id instead of db id

* chore: formatting issues
2025-12-28 11:42:25 +01:00
Nico
54068d5269
feat: allow changing the hostname (restic host) (#240) 2025-12-26 21:02:16 +01:00
Nicolas Meienberger
52a6ed6070 refactor: import local repositories use path only and not name
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
2025-12-26 17:29:42 +01:00
Jakub Trávník
7476897f87 feat(config-import): support mirrors, oneFileSystem, and optional flags
- Add mirrors support for backup schedules (copy to secondary repos)
- Add oneFileSystem flag to prevent crossing filesystem boundaries
- Support autoRemount=false for volumes (defaults to true)
- Support enabled=false for notification destinations (defaults to true)
- Optimize: move early return before dynamic imports in importBackupSchedules
- Update example config and README with new fields documentation
2025-12-23 15:29:27 +01:00
Jakub Trávník
9e9edd73a1 Merge remote-tracking branch 'origin/main' into config-import-json 2025-12-23 13:18:14 +01:00
Nico
ac9de54a7b
fix: allow arbitrary name for repositories and correctly import existing local repos (#197)
* fix: allow arbitrary name for repositories and correctly import existing local repos

* chore: rebase conflicts
2025-12-22 20:50:53 +01:00
Nico
c69d2b6445
feat: reset password cli command (#220)
* feat: reset password cli command

* refactor: wrap user password reset operations in db transaction
2025-12-22 19:20:37 +01:00
Nico
55e27ef0b5
feat: server timeout env (#219)
* feat: increase server idle timeout and allow to modify it via env

* chore(app): move auth middleware to individual controller

To clean up de main app.ts file

* chore: remove console.log
2025-12-22 17:34:27 +01:00
Jakub Trávník
883ee49ded Merge remote-tracking branch 'origin/main' into config-import-json 2025-12-22 16:27:52 +01:00
dependabot[bot]
fe8eb1326d
chore(deps-dev): bump @types/node from 24.10.4 to 25.0.3 (#209)
* chore(deps-dev): bump @types/node from 24.10.4 to 25.0.3

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 24.10.4 to 25.0.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 25.0.3
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: use rm instead of rmdir

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nicolas Meienberger <github@thisprops.com>
2025-12-21 19:51:03 +01:00
Nicolas Meienberger
c426bdcbf8 fix: sftp keep alive 2025-12-21 15:37:21 +01:00
Nico
8cdd06ec49
fix(stop): always update status to warning when stop is executed (#202)
* fix(stop): always update status to warning when stop is executed

* fix: automatically put in_progress backups to warning during startup
2025-12-21 14:25:45 +01:00
Nico
492aa4178d
feat: allow to control --one-file-system option from the schedule config (#201) 2025-12-21 14:21:08 +01:00
Jakub Trávník
8c3e85cb50 Merge remote-tracking branch 'origin/main' into config-import-json 2025-12-21 13:12:47 +01:00
Nico
fc04cfe02e
refactor(restic): use safeSpawn util instead of Bun shell (#195)
Bun has an issue with special non-ASCII charachters
https://github.com/oven-sh/bun/issues/15929 that makes commands crash if
manipulating a file with such charachter
2025-12-20 11:47:45 +01:00
Nico
598de4e078
fix: schedules not running if never run manually (#194)
* fix: backups that were never run manually are not picked up by job

* fix(mutex): prioritize waiting exclusive locks over newly added shared tasks
2025-12-20 11:28:18 +01:00
Nicolas Meienberger
febd795517 refactor: warning only when backup is aborted
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
2025-12-19 23:30:23 +01:00
Nicolas Meienberger
46c8139a23 fix: ensure proper error message when backup operation is aborted
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
2025-12-19 23:27:25 +01:00
Nicolas Meienberger
7879d88a54 fix(backups): preserve relative include/exclude pattern behavior 2025-12-19 23:18:56 +01:00
Nico
579bc89970
fix: prepend mount path in exclude patterns (#188)
* fix: prepend mount path location in exclude patterns

* test(backups): add tests suite for backend include & exclude patterns

* test: fix leaking global module mock
2025-12-19 22:35:34 +01:00
Nico
61dc07b36b
Controllers tests (#187)
* test: backups service

* refactor: create hono app in a separate file

To avoid side effects like db migration or startup scripts when testing

test(backups): add security tests to the backups controller

* ci: run typechecks, build and tests on PR

* test: controllers security tests

* chore: update lock file

* refactor: pr feedbacks
2025-12-19 19:25:21 +01:00
Jakub Trávník
6e1cc89caa Merge origin/main into config-import-json 2025-12-19 14:23:02 +01:00
Nico
94f49e2022
refactor: separate healthcheck and auto remount in two separate jobs (#179)
* refactor: separate healthcheck and auto remount in two separate jobs

* fix: try catch in volume auto remount
2025-12-18 23:03:41 +01:00
Nico
6a86de7b95
refactor: add default excludes to backups (#178)
- To avoid accidentaly backing up a repository to itself
- To avoid accidentaly backing up zerobyte's internal data
2025-12-18 22:34:21 +01:00
Nico
fd5193b5e3
refactor: reduce startup mounting noise (#177)
- Skip mount early if volume is not in error or neither mounted
- Error healthchecks early if volume is not mounted
2025-12-18 22:19:21 +01:00
Nico
a17da2562f
refactor(startup): ensure entities always use the latest configuration format (#173)
* refactor(startup): ensure entities always use the latest configuration schema

* refactor: await config updates to avoid race condition on later mount
2025-12-18 18:11:39 +01:00
Jakub Trávník
7f124f81cb refactor the import logic
- Updated README to reflect changes in config file structure and usage.
- Modified error messages for user registration to be more generic.
- Cleaned up startup logic to utilize the new config import functionality when requested.
- Adjusted JSON config structure to support user definitions.
2025-12-18 15:31:27 +01:00
Nicolas Meienberger
7951a87332 refactor: don't apply strict rate limit on /me and /status endpoints 2025-12-18 12:09:34 +01:00
Nicolas Meienberger
0838ce86bd refactor: remove cors options and fix rate limiter usage 2025-12-17 23:40:57 +01:00
Nicolas Meienberger
45e7e88b09 fix: apply middlewares before the controller definition 2025-12-17 23:35:47 +01:00
Jakub Trávník
0b2576af91 Merge remote-tracking branch 'origin/main' into config-import-json 2025-12-17 18:27:32 +01:00
Nicolas Meienberger
13e080a189 fix: apply middlewares before the controller definition
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
2025-12-17 16:23:50 +01:00
orbisai0security
3cebc1ce47 fix: resolve high vulnerability V-002
Automatically generated security fix
2025-12-17 07:47:05 +00:00
Nicolas Meienberger
f77fd86694 Merge branch 'tvarohohlavy-secrets-management'
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
2025-12-16 20:47:29 +01:00
Nicolas Meienberger
e57efcfcdc refactor: extract sortable card into its own component 2025-12-16 20:23:44 +01:00
Nicolas Meienberger
b983add4ca chore(frontend): parametrize server IP 2025-12-16 19:40:53 +01:00
Nicolas Meienberger
e39552ee68 chore: small code style improvements 2025-12-16 19:36:37 +01:00
Nicolas Meienberger
feb6353e21 chore(frontend): parametrize server IP 2025-12-16 18:02:54 +01:00
Nicolas Meienberger
fe5810b1a7 fix: circular dependency 2025-12-16 18:02:54 +01:00