Skip to content

Commit 3191734

Browse files
authored
Merge pull request #31 from buildplan/set_path
fix: Add default PATH to ensure cron execution
2 parents 8e8c17d + ec67c90 commit 3191734

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

README.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,39 @@ For those familiar with setting up backup scripts, here is a fast track to get y
3636

3737
1. **Download files**
3838

39-
```sh
40-
mkdir -p /root/scripts/backup && cd /root/scripts/backup
41-
curl -LO https://raw.githubusercontent.com/buildplan/restic-backup-script/refs/heads/main/restic-backup.sh
42-
curl -LO https://raw.githubusercontent.com/buildplan/restic-backup-script/refs/heads/main/restic-backup.conf
43-
curl -LO https://raw.githubusercontent.com/buildplan/restic-backup-script/refs/heads/main/restic-excludes.txt
44-
chmod +x restic-backup.sh
45-
```
39+
```sh
40+
mkdir -p /root/scripts/backup && cd /root/scripts/backup
41+
curl -LO https://raw.githubusercontent.com/buildplan/restic-backup-script/refs/heads/main/restic-backup.sh
42+
curl -LO https://raw.githubusercontent.com/buildplan/restic-backup-script/refs/heads/main/restic-backup.conf
43+
curl -LO https://raw.githubusercontent.com/buildplan/restic-backup-script/refs/heads/main/restic-excludes.txt
44+
chmod +x restic-backup.sh
45+
```
4646

4747
2. **Edit configuration**
4848

49-
- Update `restic-backup.conf` with repository details, backup sources, and password file.
50-
- Secure it: `chmod 600 restic-backup.conf`
49+
- Update `restic-backup.conf` with repository details, backup sources, and password file.
50+
- Secure it: `chmod 600 restic-backup.conf`
5151

5252
3. **Create password and initialize repository**
5353

54-
```sh
55-
# Create the password file (use a strong, unique password)
56-
echo 'your-very-secure-password' | sudo tee /root/.restic-password
57-
sudo chmod 400 /root/.restic-password
54+
```sh
55+
# Create the password file (use a strong, unique password)
56+
echo 'your-very-secure-password' | sudo tee /root/.restic-password
57+
sudo chmod 400 /root/.restic-password
5858
59-
# Initialize the repository
60-
sudo ./restic-backup.sh --init
61-
```
59+
# Initialize the repository
60+
sudo ./restic-backup.sh --init
61+
```
6262

6363
4. **First backup and schedule**
6464

65-
```sh
66-
# Run the first backup with verbose output
67-
sudo ./restic-backup.sh --verbose
65+
```sh
66+
# Run the first backup with verbose output
67+
sudo ./restic-backup.sh --verbose
6868
69-
# Set up a recurring schedule via wizard (systemd or cron)
70-
sudo ./restic-backup.sh --install-scheduler
71-
```
69+
# Set up a recurring schedule via wizard (systemd or cron)
70+
sudo ./restic-backup.sh --install-scheduler
71+
```
7272

7373
> Default log: `/var/log/restic-backup.log`
7474

@@ -532,9 +532,6 @@ If you prefer to manage the schedule manually instead of using the wizard, you c
532532
2. Add the following lines to schedule your backups and maintenance.
533533

534534
```crontab
535-
# Define a safe PATH that includes the location of restic
536-
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
537-
538535
# Run the Restic backup every day at 3:00 AM
539536
0 3 * * * /root/scripts/backup/restic-backup.sh > /dev/null 2>&1
540537

restic-backup.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env bash
22

33
# =================================================================
4-
# Restic Backup Script v0.38.2 - 2025.10.08
4+
# Restic Backup Script v0.38.3 - 2025.10.18
55
# =================================================================
66

7+
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
78
set -euo pipefail
89
umask 077
910

1011
# --- Script Constants ---
11-
SCRIPT_VERSION="0.38.2"
12+
SCRIPT_VERSION="0.38.3"
1213
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
1314
CONFIG_FILE="${SCRIPT_DIR}/restic-backup.conf"
1415
LOCK_FILE="/tmp/restic-backup.lock"

restic-backup.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
84a7b2750793953abf94aea82971596fedad1cb4382f1ad6264bae3ba66ecc65 restic-backup.sh
1+
568618563ca890afec48f97cb9bc88fc36d2735cd4d031951713ea4bdd8e4806 restic-backup.sh

0 commit comments

Comments
 (0)