Daily backup at 19h, zips data/ to backup/, keeps 2 max, notifies via Discord webhook. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
143 lines
3.2 KiB
Markdown
143 lines
3.2 KiB
Markdown
# Vaultwarden
|
|
|
|
Gestionnaire de mots de passe auto-heberge compatible Bitwarden, deploye avec Docker.
|
|
|
|
## Prerequis
|
|
|
|
- Docker et Docker Compose
|
|
- (Optionnel) NGINX pour le reverse proxy HTTPS
|
|
|
|
## Installation
|
|
|
|
### 1. Cloner le projet
|
|
|
|
```bash
|
|
git clone gitea@gitea.malio.fr:MALIO-DEV/Vaulwarden.git
|
|
cd Vaulwarden
|
|
```
|
|
|
|
### 2. Configurer l'environnement
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
Editer `.env` et remplacer le token admin. Pour generer un token Argon2 :
|
|
|
|
```bash
|
|
echo -n "MonMotDePasse" | argon2 "$(openssl rand -base64 32)" -e -id -k 65540 -t 3 -p 4
|
|
```
|
|
|
|
### 3. Lancer Vaultwarden
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
L'interface est accessible sur `http://localhost:8080`.
|
|
|
|
### 4. (Optionnel) HTTPS avec NGINX
|
|
|
|
```bash
|
|
sudo ./setup-vaultwarden-https.sh
|
|
```
|
|
|
|
Cela genere un certificat auto-signe et configure NGINX en reverse proxy sur le port 443.
|
|
|
|
## Mise a jour
|
|
|
|
```bash
|
|
docker compose pull
|
|
docker compose up -d
|
|
```
|
|
|
|
## Sauvegarde automatique
|
|
|
|
Un script de backup automatique est inclus : `backup-vaultwarden.sh`.
|
|
|
|
- **Frequence** : tous les jours a 19h (cron)
|
|
- **Format** : zip du dossier `data/` dans `backup/`
|
|
- **Retention** : 2 backups max (rotation automatique)
|
|
- **Notification** : Discord via webhook
|
|
|
|
### Lancer manuellement
|
|
|
|
```bash
|
|
./backup-vaultwarden.sh
|
|
```
|
|
|
|
### Installer le cron
|
|
|
|
```bash
|
|
crontab -e
|
|
# Ajouter :
|
|
0 19 * * * /usr/bin/bash /home/matt/vaultwarden/backup-vaultwarden.sh >> /home/matt/vaultwarden/logs/cron_vaultwarden.log 2>&1
|
|
```
|
|
|
|
### Sauvegarde manuelle
|
|
|
|
```bash
|
|
zip -r vaultwarden-backup-$(date +%Y%m%d).zip ./data
|
|
```
|
|
|
|
## Restauration / Migration
|
|
|
|
Pour remonter le projet sur une autre machine a partir d'une sauvegarde :
|
|
|
|
### 1. Cloner le projet sur la nouvelle machine
|
|
|
|
```bash
|
|
git clone gitea@gitea.malio.fr:MALIO-DEV/Vaulwarden.git
|
|
cd Vaulwarden
|
|
cp .env.example .env
|
|
# Editer .env avec le token admin
|
|
```
|
|
|
|
### 2. Restaurer les donnees
|
|
|
|
```bash
|
|
# Copier le backup sur la nouvelle machine puis :
|
|
cp -r /chemin/vers/data_backup ./data
|
|
|
|
# Ou decompresser une archive :
|
|
tar xzf vaultwarden_backup_XXXXXXXX.tar.gz
|
|
```
|
|
|
|
### 3. Changer le mot de passe admin
|
|
|
|
La sauvegarde contient un fichier `data/config.json` qui garde le token admin de la prod.
|
|
Pour utiliser le token defini dans `.env`, il faut supprimer l'ancien dans `config.json` :
|
|
|
|
```bash
|
|
# Editer data/config.json et supprimer la ligne "admin_token"
|
|
nano data/config.json
|
|
```
|
|
|
|
### 4. Lancer
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
Tout est restaure : comptes, mots de passe, fichiers joints.
|
|
|
|
## Structure du projet
|
|
|
|
```
|
|
.
|
|
├── docker-compose.yml # Definition du service Docker
|
|
├── setup-vaultwarden-https.sh # Script de configuration NGINX + HTTPS
|
|
├── backup-vaultwarden.sh # Script de backup automatique
|
|
├── .env # Variables d'environnement (non versionne)
|
|
├── .env.example # Exemple de configuration
|
|
├── data/ # Donnees Vaultwarden (non versionne)
|
|
├── backup/ # Backups zip (non versionne)
|
|
├── logs/ # Logs de backup (non versionne)
|
|
└── README.md
|
|
```
|
|
|
|
## Acces admin
|
|
|
|
L'interface d'administration est accessible sur `/admin` (ex: `http://localhost:8080/admin`).
|
|
Le mot de passe correspond au `VAULTWARDEN_ADMIN_TOKEN` defini dans `.env`.
|