first commit

This commit is contained in:
2026-03-18 22:33:14 +01:00
parent 14a7731503
commit f30bfd6d61
25 changed files with 1735 additions and 0 deletions

1
restic/.restic_pass Normal file
View File

@@ -0,0 +1 @@
MOT DE PASSE SUPER SECRET à mettre dans /root/.restic_pass

27
restic/README.md Normal file
View File

@@ -0,0 +1,27 @@
# Backup Restic
## IP
peu importe
## Config
Le process est complexe :
1. Créer la VM et monter le dossier /mnt/Poule/Nicephore/Photos vers /mnt/Poule/iocage/jails/Restic/root/mnt
2. VPN sur la box de maman avec WireGuard
3. ssh sur la raspi 192.168.1.168 sans mot de passe (il faut ajouter sa clé)
4. backup sur le repo restic /media/anto/Maxtor/restic-backup
Le plus complexe est le vpn. Il faut "allown_tun" dans les paramètres de la jail TrueNAS (custom properties)
## cron
```
vim /root/backup_restic.sh
crontab-e
```

46
restic/backup_restic.sh Normal file
View File

@@ -0,0 +1,46 @@
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin
# --- CONFIGURATION ---
REPO="sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup"
BACKUP_PATH="/mnt"
PASSWORD_FILE="/root/.restic_pass"
DISCORD_WEBHOOK="https://discord.com/api/webhooks/1483223739494830233/3b9BOJh27jAGB9tKhslInnSpBngIg_4cedC1s5s5D1bvL-u_Rw3EMm3U6CEkkFY2fNo5"
export RESTIC_PASSWORD_FILE=$PASSWORD_FILE
# --- Fonction notification Discord ---
send_discord() {
MESSAGE=$(printf "%s" "$1" | tr '\n' ' ' | sed 's/"/\\"/g' | cut -c1-1800)
/usr/local/bin/curl -s -o /tmp/discord_status.txt -w "%{http_code}" \
-H "Content-Type: application/json" \
-d "{\"content\":\"$MESSAGE\"}" \
"$DISCORD_WEBHOOK"
}
HOST=$(hostname)
DATE=$(date)
send_discord "**Backup restic démarrée** sur **$HOST** à $DATE"
echo "Discord HTTP status: $(cat /tmp/discord_status.txt)"
LOG=$(mktemp)
# --- BACKUP ---
restic -r $REPO backup $BACKUP_PATH 2>&1 | tee $LOG
STATUS=$?
# --- RETENTION ---
restic -r $REPO forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 >> $LOG 2>&1
restic -r $REPO prune >> $LOG 2>&1
# --- STATS ---
SUMMARY=$(grep -E "Files:|Added to the repository|processed|snapshot" $LOG)
SUMMARY=$(echo "$SUMMARY" | tr '\n' ' ' | cut -c1-1500)
send_discord "✅ **Backup réussie sur $HOST**
📦 Résumé:
$SUMMARY"

1
restic/crontab -e Normal file
View File

@@ -0,0 +1 @@
0 0 * * * /root/backup_restic.sh

10
restic/freeboxMaman.conf Normal file
View File

@@ -0,0 +1,10 @@
[Interface]
Address = 192.168.27.65/32
DNS = 212.27.38.253
MTU = 1360
PrivateKey = iMQ827w+LG6ueBcxT4MT+lNLSsmrL9kz5Ttx7Z0vlFI=
[Peer]
AllowedIPs = 0.0.0.0/0, 192.168.27.64/27, 192.168.1.0/24
Endpoint = 78.198.144.160:46755
PublicKey = Elsw3uieQgd9ayb/dDSW/t+H/DLcv5Cwrl8aOS/0xyw=

222
restic/history.txt Normal file
View File

@@ -0,0 +1,222 @@
1 23:32 ls
2 23:32 ping
3 23:32 ip a
4 23:32 cd /mnt/
5 23:32 ls
6 23:34 ping 192.168.0.112
7 23:34 ssh anto@192.168.0.112
8 23:35 ssh-keygen
9 23:35 cat .ssh/id_rsa.pub
10 23:35 ssh anto@192.168.0.112
11 23:39 ssh anto@192.168.0.112
12 23:39 ssh anto@192.168.0.112
13 23:40 cat .ssh/id_rsa.pub
14 23:41 ls
15 23:41 cd
16 23:42 cat .ssh/id_rsa.pub
17 23:42 ssh anto@192.168.0.112
18 23:43 ssh anto@192.168.0.112
19 23:43 ssh anto@192.168.0.112
20 23:44 ssh anto@192.168.0.112
21 23:45 ssh anto@192.168.0.112
22 23:45 pkg install restic
23 23:46 restic
24 23:47 restic -r sftp:anto@192.168.0.112:/srv/restic-repo init
25 23:47 ssh anto@192.168.0.112
26 23:48 restic -r sftp:anto@192.168.0.112:/srv/restic-repo init
27 23:48 ssh anto@192.168.0.112
28 23:48 restic -r sftp:anto@192.168.0.112:/home/anto/restic-repo init
29 23:49 cd /mnt/
30 23:49 ms
31 23:49 ls
32 23:50 restic -r sftp:anto@192.168.0.112:/home/anto/restic-repo --verbose backup /mnt/1997/
33 23:51 restic -r sftp:anto@192.168.0.112:/home/anto/restic-repo --verbose backup /mnt/1997/
34 23:52 restic -r sftp:anto@192.168.0.112:/home/anto/restic-repo --verbose backup /mnt/1997/ --skip-if-unchanged
35 18:34 vim /usr/local/bin/restic-backup-photos.sh
36 18:34 vim
37 18:34 pkg install vim
38 18:34 vim /usr/local/bin/restic-backup-photos.sh
39 18:35 vim /usr/local/bin/restic-backup-photos.sh
40 18:36 vim /usr/local/bin/restic-backup-photos.sh
41 18:37 chmod 700 /usr/local/bin/restic-backup-photos.sh
42 18:37 . /usr/local/bin/restic-backup-photos.sh
43 18:37 ./usr/local/bin/restic-backup-photos.sh
44 18:37 /usr/local/bin/restic-backup-photos.sh
45 19:14 l
46 19:14 cd /mnt/
47 19:14 ls
48 19:15 ls
49 19:15 ls
50 19:15 restic
51 19:20 sudo apt update
52 19:20 apt update
53 19:21 pkg install wireguard-tools
54 19:22 kldload if_wg
55 19:22 if_wg_load="YES"
56 19:23 vim /usr/local/etc/wireguard/freeboxMaman.conf
57 19:28 vim /usr/local/etc/wireguard/freeboxMaman.conf
58 19:30 wg-quick up freeboxMaman
59 19:30 sudo wg-quick up freeboxMaman
60 19:31 pkg install sudo
61 19:31 sudo wg-quick up freeboxMaman
62 19:32 sudo wg-quick up freeboxMaman
63 19:32 ls
64 19:33 vim /usr/local/etc/wireguard/freeboxMaman.conf
65 19:33 sudo wg-quick up freeboxMaman
66 19:34 kldload if_wg
67 19:34 kldload if_wg
68 19:34 kldload if_wg
69 19:34 kldload if_wg
70 19:34 sudo kldload if_wg
71 19:34 pkg install wireguard-go
72 19:35 wg-quick up freeboxMaman
73 19:35 kldload if_tun
74 19:36 pkg install wireguard
75 19:36 pkg_add wireguard-tools
76 19:36 pkg install wireguard-tools
77 19:37 wg-quick up freeboxMaman
78 19:38 kldload if_tun
79 19:38 ls /dev/tun*
80 19:38 ll /dev/tun*
81 19:38 ls
82 19:46 kldload if_tun
83 19:46 wg-quick up freeboxMaman
84 19:46 ip a
85 19:46 ifconfig
86 19:48 ls
87 19:48 cd /mnt/
88 19:48 ls
89 19:48 cd 1997/
90 19:48 ls
91 19:49 ssh anto@192.168.1.168
92 19:58 ssh-keygen -t ed25519 -C "restic VM"
93 19:58 cd /root/.ssh
94 19:58 cat id_rsa.pub
95 19:58 cat id_ed25519
96 19:59 rm id_ed25519*
97 19:59 ls
98 20:01 ssh anto@192.168.1.168
99 20:02 ssh anto@192.168.1.168
100 20:02 ssh anto@192.168.1.168
101 20:02 ssh anto@192.168.1.168
102 20:02 ping 192.168.1.168
103 20:02 ssh anto@192.168.1.168
104 20:04 ssh -o "IdentitiesOnly=yes" -i /root/.ssh/id_rsa.pub anto@192.168.1.168
105 20:05 cat /root/.ssh/id_rsa.pub
106 20:06 ssh anto@192.168.1.168
107 20:06 ssh -o "IdentitiesOnly=yes" -i /root/.ssh/id_rsa.pub anto@192.168.1.168
108 8:08 ls
109 8:08 ip a
110 8:08 ifconfig
111 8:08 ping 192.168.27.169
112 8:08 ssh anto@192.168.1.168
113 8:08 ping 192.168.1.168
114 8:31 ping 192.168.1.168
115 8:31 ip a
116 8:31 ifconfig
117 8:32 ping 192.168.27.168
118 8:32 ping 192.168.1.168
119 8:34 ssh anto@192.168.1.168
120 8:34 ls
121 8:34 cd
122 8:34 cat .ssh/id_rsa.pub
123 8:34 ssh-keygen -t ed25519 -C "restic VM"
124 8:34 cat .ssh/id_ed25519.pub
125 8:35 ssh anto@192.168.1.168
126 8:36 ssh anto@192.168.1.168
127 19:36 ls
128 19:36 ifconfig*
129 19:36 ifconfig
130 19:38 which wg-quick
131 19:38 vim /etc/rc
132 19:40 ifconfig
133 19:41 ssh anto@192.168.1.168
134 20:11 ls
135 20:11 cd /mnt/
136 20:11 ls
137 20:11 ssh anto@192.168.1.168
138 20:24 ssh anto@192.168.1.168
139 20:31 ssh anto@192.168.1.168
140 20:33 restic -r sftp:anto@192.168.1.168:/home/anto/restic-backup init
141 20:35 restic -r sftp:anto@192.168.1.168:/home/anto/restic-backup backup /mnt
142 21:47 ssh anto@192.168.1.168
143 21:48 restic -r sftp:anto@192.168.1.168:/home/anto/restic-backup backup /mnt
144 21:50 ssh anto@192.168.1.168
145 21:56 restic -r sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup init
146 21:56 restic -r sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup backup /mnt
147 9:30 restic -r sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup backup /mnt
148 9:30 ls
149 9:30 ping192.168.1.168
150 9:30 ping 192.168.1.168
151 9:30 ping192.168.1.168
152 9:31 ls /mnt/
153 9:31 ls
154 9:31 ssh anto@192.168.1.168
155 9:33 ssh anto@192.168.1.168
156 9:34 history
157 9:34 ssh anto@192.168.1.168
158 20:01 ls
159 20:01 history
160 20:02 ssh anto@192.168.1.168
161 20:05 ssh anto@192.168.1.168
162 20:09 ssh anto@192.168.1.168
163 20:20 ls /mnt/
164 20:20 restic -r sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup backup /mnt
165 20:21 restic -r sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup backup /mnt
166 22:58 vim backup_restic.sh
167 23:02 ls
168 23:03 chmod +x backup_restic.sh
169 23:03 pwd
170 23:03 cp backup_restic.sh /root/
171 23:03 cd /root/
172 23:03 ls
173 23:04 vim /root/.restic_pass
174 23:04 chmod 600 /root/.restic_pass
175 23:05 ll
176 23:05 export RESTIC_PASSWORD_FILE=/root/.restic_pass
177 23:05 vim backup_restic.sh
178 23:06 ./backup_restic.sh
179 23:06 pkg update
180 23:07 pkg install curl
181 23:07 vim backup_restic.sh
182 23:08 which restic
183 23:08 curl -H "Content-Type: application/json" -d '{"content":"test backup"}' https://discord.com/api/webhooks/1483223739494830233/3b9BOJh27jAGB9tKhslInnSpBngIg_4cedC1s5s5D1bvL-u_Rw3EMm3U6CEkkFY2fNo5
184 23:09 vim backup_restic.sh
185 23:09 ./backup_restic.sh
186 23:11 cd root/
187 23:11 ls
188 23:11 export RESTIC_PASSWORD_FILE=/root/.restic_pass
189 23:11 crontab -e
190 23:12 crontab -e
191 23:13 crontab -e
192 7:30 REPO="sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup"
193 7:30 REPO="sftp:anto@192.168.1.168:/media/anto/Maxtor/restic-backup"
194 7:31 echo $REPO
195 7:31 echo $SHELL
196 7:31 ps -p $$
197 7:31 vim backup_restic.sh
198 7:32 cat backup_restic.sh
199 7:33 zsh
200 7:34 sh
201 7:34 ./backup_restic.sh
202 7:35 vim backup_restic.sh
203 7:36 echo
204 7:36 echo $PASSWORD_FILE
205 7:37 sh
206 9:25 ls
207 9:25 cd root/
208 9:25 ls
209 9:25 cat backup_restic.sh
210 9:26 ./backup_restic.sh
211 9:27 vim backup_restic.sh
212 9:28 vim backup_restic.sh
213 9:30 ./backup_restic.sh
214 9:31 cat backup_restic.sh
215 9:32 vim backup_restic.sh
216 9:32 ./backup_restic.sh
217 9:36 vim backup_restic.sh
218 9:38 ./backup_restic.sh
219 9:38 vim backup_restic.sh
220 9:39 cat backup_restic.sh
221 9:39 vim backup_restic.sh
222 21:59 history