blob: 887a5d9a27d5c5463ba9f26695b5f6bec6f2c120 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# DRestic
<img src="logo.svg" width="120" markdown="1">
Automated, encrypted, and deduplicated backups to MEGA cloud storage using restic.
## Setup
1. Clone the repository:
```sh
git clone https://github.com/casparvitch/drestic
cd drestic
```
2. Install dependencies (supports apt, yum, pacman, zypper):
```sh
make install-deps
```
3. Run the setup script:
```sh
# For a personal machine (backs up /home/user)
make setup-user
# For a server (backs up /etc, /home, /root, etc.)
# make setup-system
```
The script will prompt for your MEGA credentials and a new restic repository password. **Store the restic password safely.**
## Usage
All common operations are handled via the `Makefile`. Run `make help` for a full list.
**Check Status**
```sh
# For user scope
make status
# For system scope
make status-system
```
**Run a Backup Manually**
```sh
make backup-now
# Monitor with: journalctl --user -fu restic-backup.service
```
**List Snapshots**
```sh
make snapshots
```
**Recover Files**
The easiest method is to mount the repository.
1. Create a mount point:
```sh
mkdir ~/restore
```
2. Mount the backup:
The repository path is now unique per host (e.g., `drestic_backups_my-server`). Find your exact path in `~/.config/restic/env`.
```sh
# For user scope (replace with your unique repo path)
RESTIC_PASSWORD_FILE=~/.config/restic/password restic mount ~/restore --repo rclone:backup_remote:/drestic_backups_my-server
```
3. Browse `~/restore/snapshots/latest/` to find your files.
4. Unmount when finished:
```sh
umount ~/restore
```
## Configuration
Configuration files are created during setup.
**Backup Paths & Exclusions**
- **User scope:** `~/.config/restic/paths` and `~/.config/restic/excludes`
- **System scope:** `/etc/restic/paths` and `/etc/restic/excludes`
Edit the `paths` file to change what is backed up. Edit the `excludes` file to add patterns to ignore. The default files contain a sensible starting point.
**Backup Schedule**
The schedule is managed by systemd timers. To change the daily 3 AM backup time:
1. Edit the timer file:
- **User scope:** `~/.config/systemd/user/restic-backup.timer`
- **System scope:** `/etc/systemd/system/restic-backup.timer`
2. Change the `OnCalendar=` line.
3. Reload systemd:
```sh
# For user scope
systemctl --user daemon-reload && systemctl --user restart restic-backup.timer
# For system scope
sudo systemctl daemon-reload && sudo systemctl restart restic-backup.timer
```
**Notifications**
To add or update Gotify push notifications, run:
```sh
make update-gotify
```
## Troubleshooting
**Repository is locked?**
```sh
# Auto-detects scope and unlocks
make unlock-repo
```
**Connection issues?**
Verify rclone can connect to your MEGA account.
```sh
rclone ls backup_remote:
```
**Something else?**
Check the logs.
```sh
# For user scope
make logs
# For system scope
make logs-system
```
|