Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd6c5ed

Browse files
committed
fix: improve install.sh on macOS and linux
1 parent 5053371 commit cd6c5ed

2 files changed

Lines changed: 237 additions & 138 deletions

File tree

README.md

Lines changed: 54 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,67 @@ Built with Go, Backrest is distributed as a standalone, lightweight binary with
5959

6060
# Installation
6161

62-
Backrest is packaged as a single executable. It can be run directly on Linux, macOS, and Windows. [restic](https://github.com/restic/restic) will be downloaded and installed on first run.
62+
Backrest is packaged as a single executable. It runs directly on Linux, macOS, and Windows. [restic](https://github.com/restic/restic) is downloaded automatically on first run.
6363

6464
Once installed, access Backrest at `http://localhost:9898` (default port). First-time setup will prompt for username and password creation.
6565

6666
> [!NOTE]
67-
> To change the default port, set the `BACKREST_PORT` environment variable (e.g., `BACKREST_PORT=0.0.0.0:9898` to listen on all interfaces)
68-
>
67+
> To change the default port, set the `BACKREST_PORT` environment variable (e.g., `BACKREST_PORT=0.0.0.0:9898` to listen on all interfaces). The install script accepts `--allow-remote-access` as a shortcut for this.
68+
>
6969
> Backrest will use your system's installed version of restic if it's available and compatible. If not, Backrest will download and install a suitable version in its data directory, keeping it updated. To use a specific restic binary, set the `BACKREST_RESTIC_COMMAND` environment variable to the desired path.
7070
71-
### Quick Start Options
71+
## Linux & macOS (Recommended)
72+
73+
The install script downloads the latest release, drops the binary into `/usr/local/bin`, and sets up the appropriate auto-start integration (systemd or OpenRC on Linux; launchd on macOS):
74+
75+
```sh
76+
curl -fsSL https://raw.githubusercontent.com/garethgeorge/backrest/main/install.sh | sudo bash
77+
```
78+
79+
Flags go after `--`:
80+
81+
```sh
82+
# Bind to all interfaces (default: 127.0.0.1:9898)
83+
curl -fsSL https://raw.githubusercontent.com/garethgeorge/backrest/main/install.sh | sudo bash -s -- --allow-remote-access
84+
85+
# Uninstall (removes service, autostart entry, and /usr/local/bin/backrest)
86+
curl -fsSL https://raw.githubusercontent.com/garethgeorge/backrest/main/install.sh | sudo bash -s -- --uninstall
87+
```
88+
89+
The service runs as your user by default (so config and data live under your `$HOME`). To install as `root` instead, pass `--root`. After install, access Backrest at `http://localhost:9898`.
90+
91+
> [!TIP]
92+
> Review [install.sh](./install.sh) before piping it into a shell. You can also clone the repo and run `./install.sh` locally; it accepts the same flags.
93+
94+
### macOS — Homebrew (alternative)
95+
96+
[Homebrew tap](https://github.com/garethgeorge/homebrew-backrest-tap):
97+
98+
```sh
99+
brew tap garethgeorge/homebrew-backrest-tap
100+
brew install backrest
101+
brew services start backrest
102+
```
103+
104+
> [!NOTE]
105+
> You may need to grant Full Disk Access to Backrest. Go to `System Preferences > Security & Privacy > Privacy > Full Disk Access` and add `/usr/local/bin/backrest`.
106+
107+
### Arch Linux (AUR)
72108

73-
1. **Pre-built Release**: Download from the [releases page](https://github.com/garethgeorge/backrest/releases)
74-
2. **Docker**: Use `ghcr.io/garethgeorge/backrest:latest` (also available on [Docker Hub](https://hub.docker.com/r/garethgeorge/backrest))
75-
- Includes rclone and common Unix utilities
76-
- For minimal image, use `ghcr.io/garethgeorge/backrest:scratch`
77-
3. **Build from Source**: See [Development](#development) section below
109+
[Backrest on AUR](https://aur.archlinux.org/packages/backrest) is third-party (not maintained by the Backrest project) and tweaks the systemd unit; see the [AUR service file](https://aur.archlinux.org/cgit/aur.git/tree/[email protected]?h=backrest) for details.
78110

79-
### Running with Docker Compose
111+
```sh
112+
paru -Sy backrest # or: yay -Sy backrest
113+
sudo systemctl enable --now backrest@$USER.service
114+
```
80115

81-
Docker image: `ghcr.io/garethgeorge/backrest`
116+
## Docker
82117

83-
Example compose file:
118+
Image: `ghcr.io/garethgeorge/backrest` (also on [Docker Hub](https://hub.docker.com/r/garethgeorge/backrest)).
119+
- Includes rclone and common Unix utilities
120+
- For a minimal image, use `ghcr.io/garethgeorge/backrest:scratch`
121+
122+
### Docker Compose
84123

85124
```yaml
86125
version: "3.8"
@@ -108,115 +147,12 @@ services:
108147
restart: unless-stopped
109148
```
110149
111-
### Linux
112-
113-
#### Option A: Install Script (Recommended)
114-
115-
```sh
116-
mkdir backrest && tar -xzvf backrest_Linux_x86_64.tar.gz -C backrest
117-
cd backrest && ./install.sh
118-
```
119-
120-
This script will:
121-
- Move the Backrest binary to `/usr/local/bin`
122-
- Create and start a systemd service running as the current user (use `sudo ./install.sh` to install as root)
123-
124-
#### Option B: Manual Installation with systemd
125-
126-
```sh
127-
sudo mv backrest /usr/local/bin/backrest
128-
sudo tee /etc/systemd/system/backrest.service > /dev/null <<EOT
129-
[Unit]
130-
Description=Backrest
131-
After=network.target
132-
133-
[Service]
134-
Type=simple
135-
User=$(whoami)
136-
ExecStart=/usr/local/bin/backrest
137-
Environment="BACKREST_PORT=127.0.0.1:9898"
138-
139-
[Install]
140-
WantedBy=multi-user.target
141-
EOT
142-
sudo systemctl enable --now backrest
143-
```
144-
145-
#### Option C: Using cron (Basic)
146-
147-
```sh
148-
sudo mv backrest /usr/local/bin/backrest
149-
(crontab -l 2>/dev/null; echo "@reboot /usr/local/bin/backrest") | crontab -
150-
```
151-
152-
**Verify Installation**
153-
- Access Backrest at `http://localhost:9898`
154-
- For the systemd service: `sudo systemctl status backrest`
155-
156-
> [!NOTE]
157-
> Adjust the `User` in the systemd service file if needed. The install script and manual systemd instructions use your current user by default.
158-
>
159-
> By default backrest listens only on localhost, you can open optionally open it up to remote connections by setting the `BACKREST_PORT` environment variable. For systemd installations, run `sudo systemctl edit backrest` and add:
160-
> ```
161-
> [Service]
162-
> Environment="BACKREST_PORT=0.0.0.0:9898"
163-
> ```
164-
> Using `0.0.0.0` allows connections from any interface.
165-
166-
#### Arch Linux
167-
168-
> [!Note]
169-
> [Backrest on AUR](https://aur.archlinux.org/packages/backrest) is not maintained by the Backrest official and has made minor adjustments to the recommended services. Please refer to [here](https://aur.archlinux.org/cgit/aur.git/tree/[email protected]?h=backrest) for details. In [[email protected]](https://aur.archlinux.org/cgit/aur.git/tree/[email protected]?h=backrest), use `restic` from the Arch Linux official repository by setting `BACKREST_RESTIC_COMMAND`. And for information on enable/starting/stopping services, please refer to [Systemd#Using_units](https://wiki.archlinux.org/title/Systemd#Using_units).
170-
171-
```shell
172-
## Install Backrest from AUR
173-
paru -Sy backrest # or: yay -Sy backrest
174-
175-
## Enable Backrest service for current user
176-
sudo systemctl enable --now backrest@$USER.service
177-
```
178-
179-
### macOS
180-
181-
#### Homebrew (Recommended)
182-
183-
Backrest is available via a [Homebrew tap](https://github.com/garethgeorge/homebrew-backrest-tap):
184-
185-
```sh
186-
brew tap garethgeorge/homebrew-backrest-tap
187-
brew install backrest
188-
brew services start backrest
189-
```
190-
191-
This method uses [Brew Services](https://github.com/Homebrew/homebrew-services) to manage Backrest. It will launch on startup and run on port 127.0.0.1:9898 by default.
192-
193-
> [!NOTE]
194-
> You may need to grant Full Disk Access to Backrest. Go to `System Preferences > Security & Privacy > Privacy > Full Disk Access` and add `/usr/local/bin/backrest`.
195-
196-
#### Manual Installation
197-
198-
1. Download the latest Darwin release from the [releases page](https://github.com/garethgeorge/backrest/releases).
199-
2. Extract and install:
200-
201-
```sh
202-
mkdir backrest && tar -xzvf backrest_Darwin_arm64.tar.gz -C backrest
203-
cd backrest && ./install.sh
204-
```
205-
206-
The install script will:
207-
- Move the Backrest binary to `/usr/local/bin`
208-
- Create a launch agent at `~/Library/LaunchAgents/com.backrest.plist`
209-
- Load the launch agent
210-
211-
> [!TIP]
212-
> Review the script before running to ensure you're comfortable with its operations.
213-
214-
### Windows
150+
## Windows
215151
216-
Download the Windows installer for your architecture from the [releases page](https://github.com/garethgeorge/backrest/releases). The installer, named Backrest-setup-[arch].exe, will place Backrest and a GUI tray application in `%localappdata%\Programs\Backrest\`. The tray application, set to start on login, monitors Backrest.
152+
Download the Windows installer for your architecture from the [releases page](https://github.com/garethgeorge/backrest/releases). The installer, named `Backrest-setup-[arch].exe`, places Backrest and a GUI tray application in `%localappdata%\Programs\Backrest\`. The tray application, set to start on login, monitors Backrest.
217153

218154
> [!TIP]
219-
> To override the default port before installation, set a user environment variable named BACKREST_PORT. On Windows 10+, navigate to Settings > About > Advanced system settings > Environment Variables. Under "User variables", create a new variable `BACKREST_PORT` with the value "127.0.0.1:port" (e.g., "127.0.0.1:8080" for port 8080). If changing post-installation, re-run the installer to update shortcuts with the new port.
155+
> To override the default port before installation, set a user environment variable named `BACKREST_PORT`. On Windows 10+, navigate to Settings > About > Advanced system settings > Environment Variables. Under "User variables", create a new variable `BACKREST_PORT` with the value `127.0.0.1:port` (e.g. `127.0.0.1:8080`). If changing post-installation, re-run the installer to update shortcuts with the new port.
220156

221157
---
222158

0 commit comments

Comments
 (0)