Skip to content

Commit

Permalink
doc: add various missing information (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects authored Oct 30, 2023
1 parent 1b3292c commit f346571
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 45 deletions.
3 changes: 3 additions & 0 deletions docs/content/configuration/variables/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ profile:
# put the content of the variable here
tag: "{{ $name }}"
```
{{% notice style="note" %}}
Variables are only valid in the file they are declared in. They cannot be shared in files loaded via `include`.
{{% /notice %}}

#### Example

Expand Down
6 changes: 3 additions & 3 deletions docs/content/installation/upgrade/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Once installed, you can easily upgrade resticprofile to the latest release using
resticprofile self-update
```

{{% notice style="note" %}}
The `self-update` command is not available when installed via homebrew.
You should use `brew upgrade resticprofile` instead.
{{% notice style="note" title="Package Managers" %}}
The `self-update` command is not available when installed via a package manager (homebrew, scoop).
You should use the upgrade built in the package manager instead.
{{% /notice %}}


Expand Down
2 changes: 1 addition & 1 deletion docs/content/installation/windows/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Resticprofile can be installed from [scoop](https://scoop.sh) main bucket:
scoop install resticprofile
```

## Manual installation (Windows)
## Manual installation

- Download the package corresponding to your system and CPU from the [release page](https://github.com/creativeprojects/resticprofile/releases)
- Once downloaded you need to open the archive and copy the binary file `resticprofile` (or `resticprofile.exe`) in your PATH.
142 changes: 101 additions & 41 deletions docs/content/schedules/systemd/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Systemd"
date: 2022-05-16T20:11:58+01:00
weight: 105
tags: ["v0.25.0"]
---


Expand All @@ -14,27 +14,121 @@ User systemd units are created under the user's systemd profile (`~/.config/syst

System units are created in `/etc/systemd/system`

## systemd calendars

resticprofile uses systemd
[OnCalendar](https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events)
format to schedule events.

Testing systemd calendars can be done with the systemd-analyze application.
systemd-analyze will display when the next trigger will happen:

```shell
systemd-analyze calendar 'daily'

Original form: daily
Normalized form: *-*-* 00:00:00
Next elapse: Sat 2020-04-18 00:00:00 CDT
(in UTC): Sat 2020-04-18 05:00:00 UTC
From now: 10h left
```

## First time schedule

When you schedule a profile with the `schedule` command, under the hood resticprofile will
- create the unit file (of type `notify`)
- create the timer file
- run `systemctl daemon-reload` (only if `schedule-permission` is set to `system`)
- run `systemctl enable`
- run `systemctl start`

## Run after the network is up

Specifying the profile option `schedule-after-network-online: true` means that the scheduled services will wait
for a network connection before running.
This is done via an [After=network-online.target](https://systemd.io/NETWORK_ONLINE/) entry in the service.

## systemd drop-in files

It is possible to automatically populate `*.conf.d`
[drop-in files](https://www.freedesktop.org/software/systemd/man/latest/systemd-system.conf.html#main-conf)
for profiles, which allows easy overriding
of the generated services, without modifying the service templates. For example:

{{< tabs groupid="config-with-json" >}}
{{% tab title="toml" %}}
```toml
version = "1"

[root]
systemd-drop-in-files = ["99-drop-in-example.conf"]
systemd-drop-in-files = ["99-drop-in-example.conf"]

[root.backup]
schedule = "hourly"
schedule-permission = "system"
schedule-lock-wait = "45m"
schedule-after-network-online = true
schedule = "hourly"
schedule-permission = "system"
schedule-lock-wait = "45m"
schedule-after-network-online = true
```
{{% /tab %}}
{{% tab title="yaml" %}}

Where `99-drop-in-example.conf` is in the same directory as `profiles.toml` and with the contents
```yaml
---
version: 1

root:
systemd-drop-in-files:
- "99-drop-in-example.conf"

backup:
schedule: hourly
schedule-permission: system
schedule-lock-wait: 45m
schedule-after-network-online: true
```
{{% /tab %}}
{{% tab title="hcl" %}}
```hcl
"version" = "1"

"root" = {
"systemd-drop-in-files" = ["99-drop-in-example.conf"]
"backup" = {
"schedule" = "hourly"
"schedule-permission" = "system"
"schedule-lock-wait" = "45m"
"schedule-after-network-online" = true
}
}
```

{{% /tab %}}
{{% tab title="json" %}}

```json
{
"version": "1",
"root": {
"systemd-drop-in-files": ["99-drop-in-example.conf"],
"backup": {
"schedule": "hourly",
"schedule-permission": "system",
"schedule-lock-wait": "45m",
"schedule-after-network-online": true
}
}
}
```

{{% /tab %}}
{{< /tabs >}}


Where `99-drop-in-example.conf` is in the same directory as `profiles.toml` and with the contents

```conf
[Service]
Environment=RCLONE_CONFIG=%d/rclone.conf
SetCredentialEncrypted=restic-repo-password: \
Expand Down Expand Up @@ -64,40 +158,6 @@ pass = $(systemd-ask-password -n "smb restic user password" | rclone obscure -)
EOF
```

## systemd calendars

resticprofile uses systemd
[OnCalendar](https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events)
format to schedule events.

Testing systemd calendars can be done with the systemd-analyze application.
systemd-analyze will display when the next trigger will happen:

```shell
systemd-analyze calendar 'daily'

Original form: daily
Normalized form: *-*-* 00:00:00
Next elapse: Sat 2020-04-18 00:00:00 CDT
(in UTC): Sat 2020-04-18 05:00:00 UTC
From now: 10h left
```

## First time schedule

When you schedule a profile with the `schedule` command, under the hood resticprofile will
- create the unit file (of type `notify`)
- create the timer file
- run `systemctl daemon-reload` (only if `schedule-permission` is set to `system`)
- run `systemctl enable`
- run `systemctl start`

## Run after the network is up

Specifying the profile option `schedule-after-network-online: true` means that the scheduled services will wait
for a network connection before running.
This is done via an [After=network-online.target](https://systemd.io/NETWORK_ONLINE/) entry in the service.

## How to change the default systemd unit and timer file using a template

By default, an opinionated systemd unit and timer are automatically generated by resticprofile.
Expand Down

0 comments on commit f346571

Please sign in to comment.