Code source wiki de Reconstruction
Modifié par john le 2026/09/20 13:31
Afficher les derniers auteurs
| author | version | line-number | content |
|---|---|---|---|
| 1 | Ordre des opérations pour remonter le serveur principal sur une machine neuve ou réinstallée, à partir de la sauvegarde Plakar et de ce wiki. | ||
| 2 | |||
| 3 | == Prérequis == | ||
| 4 | |||
| 5 | |=Élément|=Où le trouver | ||
| 6 | |Phrase secrète du dépôt Plakar|Copie hors ligne et gestionnaire de mots de passe (voir [[Sauvegarde>>Wiki Batcave John.Infrastructure.Sauvegarde.WebHome]]) | ||
| 7 | |Dépôt Plakar|SSD du [[Raspberry Pi>>Wiki Batcave John.Infrastructure.RaspberryPi.WebHome]] | ||
| 8 | |Jeton DuckDNS|Tableau de bord du site DuckDNS | ||
| 9 | |Clés Turnstile|Tableau de bord Cloudflare | ||
| 10 | |Jeton du bot Telegram|BotFather (##/token##) | ||
| 11 | |||
| 12 | == Ce qui n'est pas dans la sauvegarde == | ||
| 13 | |||
| 14 | |=Élément|=Emplacement|=Comment le recréer | ||
| 15 | |Script de sauvegarde et tâche cron|##/root/backup-plakar.sh##, ##/etc/cron.d/backup-plakar##|Page [[Sauvegarde>>Wiki Batcave John.Infrastructure.Sauvegarde.WebHome]] | ||
| 16 | |Clé SSH vers le dépôt et sa configuration|##/root/.ssh/plakar_matrix##, ##/root/.ssh/config##|Nouvelle clé, à autoriser sur le Pi | ||
| 17 | |Phrase secrète du dépôt|##/root/.plakar-pass##|Copie hors ligne | ||
| 18 | |Jeton et groupe Telegram|##/root/.backup-telegram##|BotFather | ||
| 19 | |Données de Portainer (stacks, variables)|Volume ##portainer_data##|Stacks recopiées depuis les pages de ce wiki, ou archive « Backup Portainer » | ||
| 20 | |Volumes Docker nommés (Dawarich, Wallabag, Jellystat, Photon)|##/var/lib/docker/volumes##|Bases restaurées depuis les dumps SQL ; index Photon retéléchargé | ||
| 21 | |Base d'Immich|##<DOSSIER_IMMICH>## hors ##library##|Dump SQL | ||
| 22 | |||
| 23 | == 1. Système == | ||
| 24 | |||
| 25 | * Debian 13, installation minimale avec SSH. | ||
| 26 | * ##rsyslog## : sans lui, pas de ##/var/log/auth.log## et pas de surveillance SSH par CrowdSec. | ||
| 27 | * [[Noyau Zabbly>>Wiki Batcave John.Infrastructure.ServeurPrincipal.Noyau Zabbly.WebHome]] (optionnel, Secure Boot désactivé). | ||
| 28 | * [[Lynis>>Wiki Batcave John.Infrastructure.Lynis.WebHome]] et [[Oh My Bash>>Wiki Batcave John.Infrastructure.Oh My Bash.WebHome]]. | ||
| 29 | |||
| 30 | {{code language="bash"}} | ||
| 31 | sudo apt install rsyslog lynis curl | ||
| 32 | {{/code}} | ||
| 33 | |||
| 34 | == 2. Docker == | ||
| 35 | |||
| 36 | Dépôt officiel de Docker (paquets ##docker-ce##, ##docker-ce-cli##, ##containerd.io##, ##docker-buildx-plugin##, ##docker-compose-plugin##), puis : | ||
| 37 | |||
| 38 | {{code language="bash"}} | ||
| 39 | sudo usermod -aG docker <UTILISATEUR> | ||
| 40 | docker network create proxy | ||
| 41 | docker network create docker-api | ||
| 42 | {{/code}} | ||
| 43 | |||
| 44 | == 3. Restauration des données == | ||
| 45 | |||
| 46 | Installer Plakar, créer une clé SSH et l'autoriser sur le Pi (voir « Mise en place du dépôt » dans [[Sauvegarde>>Wiki Batcave John.Infrastructure.Sauvegarde.WebHome]]), puis : | ||
| 47 | |||
| 48 | {{code language="bash"}} | ||
| 49 | sudo plakar -keyfile /root/.plakar-pass at "<REPO>" ls | ||
| 50 | sudo plakar -keyfile /root/.plakar-pass at "<REPO>" restore -to /restore <ID_INSTANTANE> | ||
| 51 | {{/code}} | ||
| 52 | |||
| 53 | Replacer ensuite à leur emplacement d'origine, avec leurs droits : | ||
| 54 | |||
| 55 | |=Restauré|=Destination | ||
| 56 | |##/restore/<APPDATA>##|##<APPDATA>## | ||
| 57 | |##/restore/<BIBLIOTHEQUE_IMMICH>##|##<BIBLIOTHEQUE_IMMICH>## | ||
| 58 | |##/restore/<CONTENU_JOPLIN>##|##<CONTENU_JOPLIN>## | ||
| 59 | |||
| 60 | {{code language="bash"}} | ||
| 61 | sudo rsync -aHAX /restore/<CHEMIN>/ <CHEMIN>/ | ||
| 62 | {{/code}} | ||
| 63 | |||
| 64 | Les dumps SQL de toutes les bases sont dans ##<APPDATA>/dumps##. | ||
| 65 | |||
| 66 | == 4. Portainer == | ||
| 67 | |||
| 68 | Voir [[Portainer>>Wiki Batcave John.Infrastructure.Portainer.WebHome]] : instance centrale, modèles d'applications, logo, puis ajout de l'environnement du Raspberry Pi (agent). | ||
| 69 | |||
| 70 | == 5. Accès et sécurité == | ||
| 71 | |||
| 72 | Dans cet ordre, pour que chaque service publié soit protégé dès son démarrage : | ||
| 73 | |||
| 74 | * [[docker-socket-proxy>>Wiki Batcave John.Infrastructure.ServeurPrincipal.DockerSocketProxy.WebHome]] | ||
| 75 | * [[DuckDNS>>Wiki Batcave John.Infrastructure.ServeurPrincipal.DuckDNS.WebHome]] | ||
| 76 | * Stack swag : [[SWAG>>Wiki Batcave John.Infrastructure.ServeurPrincipal.SWAG.WebHome]], [[Authelia>>Wiki Batcave John.Infrastructure.ServeurPrincipal.Authelia.WebHome]], [[CrowdSec>>Wiki Batcave John.Infrastructure.ServeurPrincipal.CrowdSec.WebHome]]. Nouvelle clé de bouncer : ##cscli bouncers add swag-bouncer##. | ||
| 77 | |||
| 78 | Vérifier le certificat et l'accès au portail Authelia avant de continuer. | ||
| 79 | |||
| 80 | == 6. Services == | ||
| 81 | |||
| 82 | Pour chaque service, recopier la stack de sa page, recréer ses variables d'environnement, déployer. | ||
| 83 | |||
| 84 | Bases dont les fichiers bruts ne sont pas sauvegardés : démarrer la base seule, réinjecter le dump, puis démarrer l'application. | ||
| 85 | |||
| 86 | |=Base|=Dump|=Réinjection | ||
| 87 | |MariaDB (XWiki, Passbolt, Castopod)|##<CONTENEUR>.sql## (toutes bases)|##docker exec -i <CONTENEUR> sh -c 'exec mariadb -uroot -p"$MARIADB_ROOT_PASSWORD"' < <DUMP>## | ||
| 88 | |MariaDB Nextcloud|##nextcloud.sql## (base applicative)|##docker exec -i <CONTENEUR> sh -c 'exec mariadb -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' < <DUMP>## | ||
| 89 | |PostgreSQL (tous)|##<CONTENEUR>.sql## (instance complète)|##docker exec -i <CONTENEUR> sh -c 'exec psql -U "$POSTGRES_USER" -d postgres' < <DUMP>## | ||
| 90 | |||
| 91 | Ordre conseillé : [[Passbolt>>Wiki Batcave John.Infrastructure.ServeurPrincipal.Passbolt.WebHome]] (pour retrouver les autres secrets), [[Nextcloud>>Wiki Batcave John.Infrastructure.ServeurPrincipal.Nextcloud.WebHome]], [[XWiki>>Wiki Batcave John.Infrastructure.ServeurPrincipal.Xwiki.WebHome]], puis les autres dans l'ordre du bandeau de [[Serveur principal>>Wiki Batcave John.Infrastructure.ServeurPrincipal.WebHome]]. | ||
| 92 | |||
| 93 | Passbolt a aussi besoin de sa clé serveur : ##<APPDATA>/passbolt/gpg##, restauré avec le reste. | ||
| 94 | |||
| 95 | == 7. Sauvegarde et surveillance == | ||
| 96 | |||
| 97 | * Script, tâche cron, fichier Telegram : [[Sauvegarde>>Wiki Batcave John.Infrastructure.Sauvegarde.WebHome]]. | ||
| 98 | * Premier lancement à la main, puis attendre le ✅. | ||
| 99 | * [[Watchtower>>Wiki Batcave John.Infrastructure.ServeurPrincipal.WebHome]] et le workflow de notification de [[n8n>>Wiki Batcave John.Infrastructure.ServeurPrincipal.n8n.WebHome]]. | ||
| 100 | * Premier audit : ##sudo lynis audit system##. |