Commit Graph

46 Commits

Author SHA1 Message Date
Jörg Thalheim
13cc579932
Merge pull request #301528 from Mic92/borgbackup-fix
nixos/borgbackup: fix network-online.target warning
2024-04-09 19:39:11 +02:00
Bjørn Forsman
786141228f nixos/borgbackup: fix directory ownership regression
Re-add separate creation of the ~/.config and ~/.cache directories so
that they get correct ownership. Or else they get owned by root.

systemd-tmpfiles also warns about it:

  machine # [    3.022195] systemd-tmpfiles[472]: Detected unsafe path transition /home/user1 (owned by user1) → /home/user1/.cache (owned by root) during canonicalization of home/user1/.cache.
  machine # [    3.024566] systemd-tmpfiles[472]: Detected unsafe path transition /home/user1 (owned by user1) → /home/user1/.config (owned by root) during canonicalization of home/user1/.config.

Fixes: 8d3cf213db ("nixos/borgbackup: replace activationScript via tmpfiles")
2024-04-06 16:38:11 +02:00
Jörg Thalheim
44fd320df6 nixos/borgbackup: fix network-online.target warning
service runs after network-online.target but doesn't depend on it.
2024-04-04 13:49:40 +02:00
nikstur
8d3cf213db nixos/borgbackup: replace activationScript via tmpfiles 2023-12-29 03:41:45 +01:00
h7x4
5ec449a6be nixos/borgbackup: add listOf str types to extraArgs 2023-12-06 23:12:21 +01:00
h7x4
79d3d59f58
treewide: replace mkPackageOptionMD with mkPackageOption 2023-11-30 19:03:14 +01:00
amesgen
bbf7f58b57
nixos/borgbackup: add package option
Co-authored-by: Lin Jian <me@linj.tech>
2023-10-07 16:27:57 +02:00
Felix Buehler
f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
Sophie Tauchert
8af23590d3 nixos/borgbackup: fix extraCompactArgs
Fixes the extraCompactArgs introduced with #224072 as the variable
currently isn't added to the script's environment.
2023-05-14 16:51:24 +02:00
ajs124
d37ee8222b nixos/borgbackup: run compact after prune 2023-04-11 19:48:16 +02:00
pennae
0a6e6cf7e6 nixos/manual: render module chapters with nixos-render-docs
this converts meta.doc into an md pointer, not an xml pointer. since we
no longer need xml for manual chapters we can also remove support for
manual chapters from md-to-db.sh

since pandoc converts smart quotes to docbook quote elements and our
nixos-render-docs does not we lose this distinction in the rendered
output. that's probably not that bad, our stylesheet didn't make use of
this anyway (and pre-23.05 versions of the chapters didn't use quote
elements either).

also updates the nixpkgs manual to clarify that option docs support all
extensions (although it doesn't support headings at all, so heading
anchors don't work by extension).
2023-01-27 20:07:34 +01:00
Bjørn Forsman
0f0929f4aa nixos/borgbackup: fix ~/.cache, ~/.config ownership
Invoke `install` separately for each directory to get ownership right --
i.e. not always owned by root. When owned by root, user sessions break
as no user processes are allowed to create directores there. On normal
systems the directories already exist, but in clean environments / NixOS
test VMs, the bug shows.

Before:
  $ namei -l /home/user1/.cache/borg
  f: /home/user1/.cache/borg
  drwxr-xr-x root  root  /
  drwxr-xr-x root  root  home
  drwx------ user1 users user1
  drwxr-xr-x root  root  .cache
  drwxr-xr-x user1 users borg

After:
  $ namei -l /home/user1/.cache/borg
  f: /home/user1/.cache/borg
  drwxr-xr-x root  root  /
  drwxr-xr-x root  root  home
  drwx------ user1 users user1
  drwxr-xr-x user1 users .cache
  drwxr-xr-x user1 users borg
2022-12-28 13:07:16 +01:00
Naïm Favier
723eb8d9b8
Merge pull request #205479 from IzumiRaine/borgbackup-patterns 2022-12-17 17:00:02 +01:00
Ryan Lahfa
4428f9f5e9
Merge pull request #198239 from jacobgreenleaf/jacobg-borg-inhibit
nixos/borgbackup: Add option for inhibiting sleep
2022-12-17 00:45:10 +01:00
Izumi Raine
cb4547a433 nixos/borgbackup: add option "patterns" 2022-12-10 16:49:34 +01:00
Naïm Favier
75e0609a00
nixos/borgbackup: fix newline escaping with optional arguments
The newline must always be escaped, otherwise `extraPruneArgs` will be treated as a separate command if `prune.prefix` is unset.
2022-12-10 16:46:34 +01:00
Bjørn Forsman
bbcfd192a8 nixos/borgbackup: change --prefix to --glob-archives
Fixes warning from `borg prune`:

  Warning: "--prefix" has been deprecated. Use "--glob-archives 'yourprefix*'" (-a) instead.
2022-12-07 02:24:00 +01:00
Jacob Greenleaf
0111e9547e nixos/borgbackup: Add option for inhibiting sleep
Adds a new option for backup jobs `inhibitsSleep` which prevents
the system from going to sleep while a backup is in progress.
Uses `systemd-inhibit`, which holds a "lock" that prevents the
system from sleeping while the process it invokes is running.

This did require wrapping the existing backup script using
`writeShellScript` so that it could be run by `systemd-inhibit`.
2022-12-04 19:57:41 -08:00
Artturin
6910a4eea0 treewide: makeWrapper to nativeBuildInputs
this should be all of them other than the failed splices
found with nixpkgs-lint
2022-09-26 17:53:26 +03:00
Sebastián Mancilla
10a745eac8
Merge pull request #179896 from erikarvstedt/fix-bash-exit-handler
treewide: fix bash exit handlers
2022-08-14 21:42:41 -04:00
pennae
087472b1e5 nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pennae
423545fe48 nixos/*: normalize manpage references to single-line form
now nix-doc-munge will not introduce whitespace changes when it replaces
manpage references with the MD equivalent.

no change to the manpage, changes to the HTML manual are whitespace only.
2022-08-05 18:34:50 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Erik Arvstedt
3f54dfa475
treewide: fix bash exit handlers
Transform exit handlers of the form
trap cleanup EXIT [INT] [TERM] [QUIT] [HUP] [ERR]
  (where cleanup is idempotent)
to
trap cleanup EXIT

This fixes a common bash antipattern.

Each of the above signals causes the script to exit. For each signal,
bash first handles the signal by running `cleanup` and then runs
`cleanup` again when handling EXIT.
(Exception:  `vscode/*` prevents the second run of `cleanup` by removing
the trap in cleanup`).

Simplify the cleanup logic by just trapping exit, which is always run
when the script exits due to any of the above signals.

Note: In case of borgbackup, the exit handler is not idempotent, but just
trapping EXIT guarantees that it's only run once.
2022-07-02 16:13:12 +02:00
Naïm Favier
6565458f9d
nixos/borgbackup: remove literalDocBook in description 2022-01-20 20:10:26 +01:00
Felix Buehler
7caa6f4de4 nixos/borgbackup: move systemd.timers logic into single block 2022-01-18 12:53:36 +01:00
Felix Buehler
91dfaa5453 nixos/borgbackup: start remote backup only if network is available 2022-01-17 15:42:39 +01:00
blargg
697198834c nixos/borgbackup: Add a persistentTimer option.
Persistent starts the backup service on power on if it was missed while
the system was powered down, for example.
2022-01-17 15:42:37 +01:00
Winter
2104608642 nixos/borgbackup: allow empty archive base name 2022-01-16 10:41:04 -05:00
Kerstin Humm
ac8a9c3f03
Revert "nixos/borgbackup: specify systemd WorkingDirectory"
This reverts commit 62ab77a322.

This broke nixosTests.borgbackup:
https://github.com/NixOS/nixpkgs/pull/143995#issuecomment-985136152
2021-12-03 12:21:13 +01:00
Kerstin Humm
62ab77a322
nixos/borgbackup: specify systemd WorkingDirectory 2021-10-31 13:39:46 +01:00
pennae
1fa5e13f30 nixos/borgbackup: allow dump scripts as stdin inputs
borg is able to process stdin during backups when backing up the special path -,
which can be very useful for backing up things that can be streamed (eg database
dumps, zfs snapshots).
2021-10-22 16:31:50 -04:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Guillaume Girol
bc3bca822a nixos: define the primary group of users where needed 2021-09-12 14:59:30 +02:00
Robert Hensing
fbafeb7ad5 treewide: runCommandNoCC -> runCommand
This has been synonymous for ~5y.
2021-08-15 17:36:41 +02:00
Symphorien Gibol
7a87973b4c nixos/users: require one of users.users.name.{isSystemUser,isNormalUser}
As the only consequence of isSystemUser is that if the uid is null then
it's allocated below 500, if a user has uid = something below 500 then
we don't require isSystemUser to be set.

Motivation: https://github.com/NixOS/nixpkgs/issues/112647
2021-04-14 20:40:00 +02:00
Jörg Thalheim
35359bb3e3
nixos/borgbackup: fix evaluation 2020-04-02 12:40:02 +01:00
Niklaus Giger
c027937d9a borgbackup: Moved documentation to NixOS manual and added examples for
* creating a local backup
* creating a borgbackup server
* backing up to a borgbackup server
* hints about the Vorta graphical desktop application
* Added documentation about Vorta desktop client

Tested the examples locally and with my borgbase.com account.
2020-04-01 22:21:10 +02:00
Yorick van Pelt
470c8a2a36 nixos/borgbackup: install job wrappers to systemPackages for easy borg access
Currently to run borg job manually, you have to use systemctl:
```
$ systemctl start borgbackup-job-jobname.service
```

This commit makes wrappers around borg jobs available in $PATH, which have
BORG_REPO and connection args set correctly:
```
$ borg-job-jobname list
$ borg-job-jobname mount ::jobname-archive-2019-12-25T00:01:29 /mnt/some-path
$ borg-job-jobname create ::test /some/path
```

Closes: https://github.com/NixOS/nixpkgs/pull/64888
Co-authored-by: Danylo Hlynskyi <abcz2.uprola@gmail.com>
2019-12-26 07:50:03 +02:00
Maximilian Bosch
2dfc67517a
nixos/borgbackup: add option to allow removable devices
When having backup jobs that persist to a removable device like an
external HDD, the directory shouldn't be created by an activation script
as this might confuse auto-mounting tools such as udiskie(8).

In this case the job will simply fail, with the former approach
udiskie ran into some issues as the path `/run/media/ma27/backup` was
already there and owned by root.
2019-10-14 17:28:44 +02:00
Yorick
4d68e82dbc nixos/borgbackup: use coercedTo instead of apply on paths (#53756)
so multiple declarations merge properly
2019-01-10 16:34:02 +01:00
Robert Schütz
74e283403c
nixos/borgbackup: allow paths to be empty or relative (#51275)
This former necessary in order to exclusively use `--pattern` or `--patterns-from`.
Fixes #51267.
2018-11-30 17:37:50 +01:00
volth
2e979e8ceb [bot] nixos/*: remove unused arguments in lambdas 2018-07-20 20:56:59 +00:00
Robert Schütz
3c0daa19e2 nixos/borgbackup: make extraArgs a shell variable
in line with the other extra*Args variables
2018-05-24 13:53:25 +02:00
Simon Lackerbauer
1433ec60af
nixos/borgbackup: let borg write to disk and see /tmp, add extraArgs 2018-05-24 04:40:45 +02:00
Robert Schütz
fdf0f037be nixos/borgbackup: init 2018-03-19 13:12:47 +01:00