Skip to content

Commit cf808b0

Browse files
Merge from schedule branch
1 parent 9dceff5 commit cf808b0

File tree

1 file changed

+62
-47
lines changed

1 file changed

+62
-47
lines changed

README.md

+62-47
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ With resticprofile:
1919
* You can send a backup stream via _stdin_
2020
* You can start restic at a lower or higher priority (Priority Class in Windows, *nice* in all unixes) and/or _ionice_ (only available on Linux)
2121
* It can check that you have enough memory before starting a backup. (I've had some backups that literally killed a server with swap disabled)
22+
* **[new for v0.9.0]** You can generate cryptographically secure random keys to use as a restic key file
2223
* **[new for v0.9.0]** You can easily schedule backups, retentions and checks (works for *systemd*, *launchd* and *windows task scheduler*)
23-
* You can generate cryptographically secure random keys to use as a restic key file
2424

2525
The configuration file accepts various formats:
2626
* [TOML](https://github.com/toml-lang/toml) : configuration file with extension _.toml_ and _.conf_ to keep compatibility with versions before 0.6.0
@@ -52,7 +52,7 @@ For the rest of the documentation, I'll be mostly showing examples using the TOM
5252
* [Command line reference](#command-line-reference)
5353
* [Minimum memory required](#minimum-memory-required)
5454
* [Generating random keys](#generating-random-keys)
55-
* [Scheduled backups (please note this is work in progress for version 0\.9\.0)](#scheduled-backups-please-note-this-is-work-in-progress-for-version-090)
55+
* [Scheduled backups](#scheduled-backups)
5656
* [Schedule configuration](#schedule-configuration)
5757
* [schedule\-permission](#schedule-permission)
5858
* [schedule\-log](#schedule-log)
@@ -585,7 +585,7 @@ To generate a different size of key, you can specify the bytes length on the com
585585
$ resticprofile random-key 2048
586586
```
587587

588-
## Scheduled backups (please note this is work in progress for version 0.9.0)
588+
## Scheduled backups
589589

590590
resticprofile is capable of managing scheduled backups for you:
591591
- using **systemd** where available (Linux and various unixes)
@@ -680,7 +680,7 @@ Wed..Sat,Tue 12-10-15 1:2:3 → Tue..Sat 2012-10-15 01:02:03
680680

681681
The `schedule` can be a string or an array of string (to allow for multiple schedules)
682682

683-
Here's an example of a YAML configuration for Windows:
683+
Here's an example of a YAML configuration:
684684

685685
```yaml
686686
default:
@@ -696,8 +696,7 @@ self:
696696
- "Sat,Sun 0,12:00" # twice a day on week-ends
697697
schedule-permission: user
698698
retention:
699-
schedule:
700-
- "sun 3:30"
699+
schedule: "sun 3:30"
701700
schedule-permission: user
702701
```
703702
@@ -708,13 +707,13 @@ resticprofile accepts these internal commands:
708707
- unschedule
709708
- status
710709
711-
Please note the display of the status command will be OS dependant.
712-
713-
If you create a task with `user` permission under Windows, you will need to enter your password to validate the task. It's a requirement of the task scheduler. I'm inviting you to review the code to make sure I'm not emailing your password to myself. Seriously you shouldn't trust anyone.
710+
Please note the display of the `status` command will be OS dependant.
714711

715712
#### Examples of scheduling commands under Windows
716713

717-
Example of the schedule command under Windows (with git bash):
714+
If you create a task with `user` permission under Windows, you will need to enter your password to validate the task. It's a requirement of the task scheduler. I'm inviting you to review the code to make sure I'm not emailing your password to myself. Seriously you shouldn't trust anyone.
715+
716+
Example of the `schedule` command under Windows (with git bash):
718717

719718
```
720719
$ resticprofile -c examples/windows.yaml -n self schedule
@@ -864,37 +863,6 @@ Created symlink /home/user/.config/systemd/user/timers.target.wants/resticprofil
864863
2020/07/23 17:08:51 scheduled job test1/check created
865864
```
866865
867-
868-
#### Examples of scheduling commands under macOS
869-
870-
Under macOS resticprofile is asking if you want to start a profile right now so you can give the access needed to the agent.
871-
872-
```
873-
% resticprofile -v -c examples/private/azure.yaml -n self schedule
874-
875-
Analyzing backup schedule 1/1
876-
=================================
877-
Original form: *:0,15,30,45:00
878-
Normalized form: *-*-* *:00,15,30,45:00
879-
Next elapse: Tue Jul 28 23:00:00 BST 2020
880-
(in UTC): Tue Jul 28 22:00:00 UTC 2020
881-
From now: 2m34s left
882-
883-
884-
By default, a macOS agent access is restricted. If you leave it to start in the background it's likely to fail.
885-
You have to start it manually the first time to accept the requests for access:
886-
887-
% launchctl start local.resticprofile.self.backup
888-
889-
Do you want to start it now? (Y/n):
890-
2020/07/28 22:57:26 scheduled job self/backup created
891-
```
892-
893-
Right after you started the profile, you should get some popup asking you to grant access to various thing. If you backup your files to an external repository on a network you will get this request:
894-
895-
!["resticprofile" would like to access files on a network volume](https://github.com/creativeprojects/resticprofile/raw/master/network_volume.png)
896-
897-
898866
The `status` command shows a combination of `journalctl` displaying errors (only) in the last month and `systemctl status`:
899867
900868
```
@@ -942,7 +910,7 @@ Jul 28 15:10:07 Desktop76 systemd[2951]: Started check timer for profile test1 i
942910

943911
```
944912
945-
And unschedule:
913+
And `unschedule`:
946914
947915
```
948916
$ resticprofile -c examples/linux.yaml -n test1 unschedule
@@ -952,6 +920,42 @@ Removed /home/user/.config/systemd/user/timers.target.wants/resticprofile-check@
952920
2020/07/23 17:13:42 scheduled job test1/check removed
953921
```
954922
923+
#### Examples of scheduling commands under macOS
924+
925+
macOS has a very tight protection system when running scheduled tasks (also called agents).
926+
927+
Under macOS, resticprofile is asking if you want to start a profile right now so you can give the access needed to the task (it will consist on a few popup windows)
928+
929+
Here's an example of scheduling a backup to Azure (which needs network access):
930+
931+
```
932+
% resticprofile -v -c examples/private/azure.yaml -n self schedule
933+
934+
Analyzing backup schedule 1/1
935+
=================================
936+
Original form: *:0,15,30,45:00
937+
Normalized form: *-*-* *:00,15,30,45:00
938+
Next elapse: Tue Jul 28 23:00:00 BST 2020
939+
(in UTC): Tue Jul 28 22:00:00 UTC 2020
940+
From now: 2m34s left
941+
942+
943+
By default, a macOS agent access is restricted. If you leave it to start in the background it's likely to fail.
944+
You have to start it manually the first time to accept the requests for access:
945+
946+
% launchctl start local.resticprofile.self.backup
947+
948+
Do you want to start it now? (Y/n):
949+
2020/07/28 22:57:26 scheduled job self/backup created
950+
```
951+
952+
Right after you started the profile, you should get some popup asking you to grant access to various files/folders/network.
953+
954+
If you backup your files to an external repository on a network, you should get this popup window:
955+
956+
!["resticprofile" would like to access files on a network volume](https://github.com/creativeprojects/resticprofile/raw/master/network_volume.png)
957+
958+
955959
### Changing schedule-permission from user to system, or system to user
956960
957961
If you need to change the permission of a schedule, **please be sure to `unschedule` the profile before**.
@@ -1245,7 +1249,7 @@ stdin:
12451249
```
12461250

12471251
Also here's an example of a configuration file in HCL:
1248-
``` hcl
1252+
```hcl
12491253
global {
12501254
priority = "low"
12511255
ionice = true
@@ -1370,21 +1374,32 @@ When you schedule a profile with the `schedule` command, under the hood resticpr
13701374
- run `systemctl enable`
13711375
- run `systemctl start`
13721376

1373-
**Please note the first time you schedule a profile, the `systemctl start` command will trigger a immediate start of the profile. It usually means if you have a backup and a check, it will start both straight away. So far I haven't found a way of preventing it.**
13741377

13751378
## Using resticprofile and launchd on macOS
13761379

13771380
`launchd` is the service manager on macOS. resticprofile can schedule a profile via a _user agent_ or a _daemon_ in launchd.
13781381

13791382
### User agent
13801383

1381-
A user agent is generated when you set `schedule-permission` to `user`.
1384+
A user agent is generated when you set `schedule-permission` to `user`.
13821385

13831386
It consists of a `plist` file in the folder `~/Library/LaunchAgents`:
13841387

1385-
A user agent **mostly** runs with the privileges of the user. But if you backup some specific files, like your contacts or your calendar for example, you will need to give more permissions to resticprofile **and** restic
1388+
A user agent **mostly** runs with the privileges of the user. But if you backup some specific files, like your contacts or your calendar for example, you will need to give more permissions to resticprofile **and** restic.
1389+
1390+
For this to happen, you need to start the agent or daemon from a console window first (resticprofile will ask if you want to do so)
1391+
1392+
If your profile is a backup profile called `remote`, the command to run manually is:
1393+
1394+
```
1395+
% launchctl start local.resticprofile.remote.backup
1396+
```
1397+
1398+
Once you grant the permission, the background agents/daemon will be able to run normally.
1399+
1400+
There's some information in this thread: https://github.com/restic/restic/issues/2051
13861401

1387-
TODO _write up some information about FDA_
1402+
*TODO: I'm going to try to compile a comprehensive how-to guide from all the information from the thread. Stay tuned!*
13881403

13891404
#### Special case of schedule-permission=user with sudo
13901405

0 commit comments

Comments
 (0)