diff --git a/.gitignore b/.gitignore index 784bde5..e791638 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ on_exit_*.txt restictray +restictray.tar.* config.json restictray.app/ .DS_Store diff --git a/README.md b/README.md index 610c9ca..290d338 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ # Restictray -A macOS system tray wrapper around [Restic](https://restic.net/), the Go-powered cmd-line backup tool. +A macOS and Linux system tray wrapper around [Restic](https://restic.net/), the Go-powered cmd-line backup tool. With Restictray, you can monitor and trigger backups from the system tray: ![](img/restictray.jpg) +Also tested & working on Linux: + +![](img/linux.jpg) + Restictray is designed in such a way that it checks whether or not a backup is needed every hour by looking at the latest date in the `restic snapshot` output that's also part of the menu. If the backup command fails, the SFTP network goes down, or your laptop is offline, it will resume next time it's booted. It's also possible to trigger a backup manually. @@ -19,32 +23,34 @@ This was designed for my wife to access backups with a button press. Restictray currently expects the following files in `~/.restic/`: -1. `password.txt` as hardcoded `--password-file` argument -2. `excludes.txt` as hardcoded `--exclude-file` argument -3. `config.json` that configures the repository, the folder(s)/file(s) to backup, and the interval in hours: +1. `password.txt` as hardcoded `--password-file` argument. If not present, creates the file with password "password". +2. `excludes.txt` as hardcoded `--exclude-file` argument. If not present, creates an empty excludes file. +3. `config.json` that configures the repository, the folder(s)/file(s) to backup. If not present, creates these defaults: ```json { - "repository": "sftp:user@server:/somewhere/resticdir", + "repository": "/tmp", "backup": "/Users/username", "backupTimeInHours": 24 } ``` -Where `repository` is the restic `-r` argument and `backup` the folder(s)/file(s) fed into the `backup` command. +If `config.json` exists but the key `backupTimeInHours` is absent, it will default to **24**: backup once a day. + +Where `repository` is the restic `-r` argument and `backup` the folder(s)/file(s) fed into the `backup` command. That is, you can use SFTP or S3 or ... as you'd normally do, using for instance `sftp:user@server:/somewhere/resticdir` as a `repository` value. **The repository should already be initialized!** You'll have to do this yourself using `restic -r [repo] init`. -If `backupTimeInHours` is absent, it will default to **24**: backup once a day. - For more information on how the restic arguments themselves work, please see the restic docs at https://restic.readthedocs.io/en/stable/. ### Dev config -If environment variable `RESTICTRAY_DEV` is set, Restictray configures Zerolog to use stdout and the prettyprint formatter instead of the external log, plus it relies on the `restic` command in `$PATH` instead of looking for it in the currently executing folder. +If environment variable `RESTICTRAY_DEV` is set, Restictray configures Zerolog to use stdout and the prettyprint formatter instead of the external log. ## Deploying +### macOS + Restictray can be wrapped as a macOS `.app` folder that can be distributed. See `build.sh` on how to do this---I've used `fyne package`: see docs at https://developer.fyne.io/started/packaging. ![](img/restictray-app.jpg) @@ -53,6 +59,11 @@ The app also wraps the `restic` binary so no local install is needed. Please note that the current supplied one in `build/` is an ARM64 macOS-specific binary for that very reason. +### Linux + +Just `go build` and copy the binary to install. On Linux you will need to install Restic yourself using your favorite package manager or via the [Restic installation page](https://restic.net/#installation). + ## Troubleshooting -Restictray uses Lumberjack and Zerolog to log info to `~/.restic/log.txt`. If a command fails, it should be logged there. \ No newline at end of file +Restictray uses Lumberjack and Zerolog to log info to `~/.restic/log.txt`. If a command fails, it should be logged there. + diff --git a/TODO.md b/TODO.md index 3d62acd..597437a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,10 +1,10 @@ # TODO -- [ ] Write README +- [X] Write README - [X] `restic backup` can take a long time: stream output to logging somehow to keep track of what it's doing. Stop using `--json` for `backup`, generates way too much JSON log info. -- [ ] Make Restictray non-dependent on existing config in `~/.restic`: - - [ ] Create default files if not existing? +- [X] Make Restictray non-dependent on existing config in `~/.restic`: + - [X] Create default files if not existing? - [ ] Create a config dialog in https://developer.fyne.io/ - [ ] Add additional resilience: - [X] What if SSH backup and network goes down? Do a `ping` before backup? Is there a timeout from the `restic` command itself? @@ -15,4 +15,4 @@ - [ ] `restic list locks` showed a dangling one; PID of already gone `restic` process. Why? Unable to reproduce? - [ ] Verify backups with `restic check`? If not okay, remove (snapshot/folder?) and rebackup? What's the plan then? - [ ] Implement `restic init`, reducing the need for an existing backup -- [ ] Cross-platform compatibility with Linux? Shouldn't be hard. \ No newline at end of file +- [X] Cross-platform compatibility with Linux? Shouldn't be hard. \ No newline at end of file diff --git a/img/linux.jpg b/img/linux.jpg new file mode 100644 index 0000000..987c4e0 Binary files /dev/null and b/img/linux.jpg differ