notes moving
This commit is contained in:
parent
7dc0168827
commit
2313602027
7 changed files with 2 additions and 0 deletions
117
content/post/notes/borg/index.md
Normal file
117
content/post/notes/borg/index.md
Normal file
|
@ -0,0 +1,117 @@
|
|||
---
|
||||
title: "Borg"
|
||||
date: 2025-05-23T09:14:36+02:00
|
||||
tags:
|
||||
- 100DaysToOffload
|
||||
draft: false
|
||||
author: "Colmaris"
|
||||
toc: true
|
||||
---
|
||||
## Créer un dépôt distant
|
||||
|
||||
*Ne pas oublié d'activité l'authentification par cléf pour SSH*
|
||||
|
||||
```shell
|
||||
borg init -e none ssh://utilisateur@serveur:port/chemin/sur/le/dépôt/distant
|
||||
```
|
||||
|
||||
* `-e none` : signifie que le dépôt n'est pas chiffré, pour chiffré le dépôt on utilisera l'options `repokey`
|
||||
|
||||
## Créer une sauvegarde
|
||||
|
||||
```shell
|
||||
borg create --verbose --stats --compression lz4 /repertoire/source ssh://utilisateur@serveur:port/chemin/sur/le/dépôt/distant::nom-de-sauvegarde
|
||||
```
|
||||
|
||||
## Lister les sauvegardes
|
||||
|
||||
```shell
|
||||
borg list ssh://utilisateur@serveur:port/chemin/sur/le/dépôt/distant
|
||||
```
|
||||
|
||||
## Restaurer une sauvegarde
|
||||
|
||||
```shell
|
||||
borg extract ssh://utilisateur@serveur:port/chemin/sur/le/dépôt/distant::nom-de-la-sauvegarde-a-extraire /dossier/dextraction
|
||||
```
|
||||
|
||||
## Automatisation
|
||||
|
||||
Placer le script dans `/etc/cron.daily/`pour une sauvegarde quotidienne vers 5h du matin. On peut aussi utiliser les dossier `cron.weekly`ou `cron.monthly` par exemple.
|
||||
|
||||
```shell
|
||||
#!/bin/bash
|
||||
|
||||
# Setting this, so the repo does not need to be given on the commandline:
|
||||
export BORG_REPO=ssh://utilisateur@serveur:port/chemin/sur/le/dépôt/distant
|
||||
|
||||
# See the section "Passphrase notes" for more infos.
|
||||
#export BORG_PASSPHRASE=''
|
||||
|
||||
# some helpers and error handling:
|
||||
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
|
||||
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
|
||||
|
||||
info "Starting backup"
|
||||
|
||||
# Backup the most important directories into an archive named after
|
||||
# the machine this script is currently running on:
|
||||
|
||||
borg create \
|
||||
--verbose \
|
||||
--filter AME \
|
||||
--list \
|
||||
--stats \
|
||||
--show-rc \
|
||||
--compression lz4 \
|
||||
--exclude-caches \
|
||||
--exclude 'home/*/.cache/*' \
|
||||
--exclude 'var/tmp/*' \
|
||||
\
|
||||
::'{hostname}-{now}' \
|
||||
/dossier/a/sauvegarder \
|
||||
/dossier/a/sauvegarder \
|
||||
/dossier/a/sauvegarder
|
||||
|
||||
backup_exit=$?
|
||||
|
||||
info "Pruning repository"
|
||||
|
||||
# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly
|
||||
# archives of THIS machine. The '{hostname}-*' matching is very important to
|
||||
# limit prune's operation to this machine's archives and not apply to
|
||||
# other machines' archives also:
|
||||
|
||||
borg prune \
|
||||
--list \
|
||||
--glob-archives '{hostname}-*' \
|
||||
--show-rc \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 12 \
|
||||
--keep-yearly 5
|
||||
|
||||
prune_exit=$?
|
||||
|
||||
# actually free repo disk space by compacting segments
|
||||
|
||||
info "Compacting repository"
|
||||
|
||||
borg compact
|
||||
|
||||
compact_exit=$?
|
||||
|
||||
# use highest exit code as global exit code
|
||||
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
|
||||
global_exit=$(( compact_exit > global_exit ? compact_exit : global_exit ))
|
||||
|
||||
if [ ${global_exit} -eq 0 ]; then
|
||||
info "Backup, Prune, and Compact finished successfully"
|
||||
elif [ ${global_exit} -eq 1 ]; then
|
||||
info "Backup, Prune, and/or Compact finished with warnings"
|
||||
else
|
||||
info "Backup, Prune, and/or Compact finished with errors"
|
||||
fi
|
||||
|
||||
exit ${global_exit}
|
||||
```
|
73
content/post/notes/mariadb/index.md
Normal file
73
content/post/notes/mariadb/index.md
Normal file
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
title: "Mariadb"
|
||||
date: 2025-03-04T13:53:19+01:00
|
||||
tags:
|
||||
- adminsys
|
||||
- mariadb
|
||||
---
|
||||
Compilation de mes notes sur Mariadb.<!--more-->
|
||||
|
||||
|
||||
# Créer un utilisateur mariadb limité à une seule base de donnée.
|
||||
|
||||
```shell
|
||||
CREATE DATABASE `mabase` ; GRANT ALL PRIVILEGES ON `mabase`.* TO "monlogin"@"%" identified by 'monpass'; FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
* Pour une connexion en locale on remplace % par localhost.
|
||||
* Pour une connexion depuis un serveur dédié on replace % par l’adresse ip de dit serveur.
|
||||
* Le % permet de se connecter depuis n’importe quel machine public ou privé.
|
||||
|
||||
# Supprimer une Base et son utilisateur.
|
||||
|
||||
Pour supprimer un utilisateur.
|
||||
|
||||
```shell
|
||||
DROP USER user@"%";
|
||||
```
|
||||
|
||||
Supprimer une base de données.
|
||||
|
||||
```shell
|
||||
DROP DATABASE nom-base;
|
||||
```
|
||||
|
||||
# Sauvegarder
|
||||
|
||||
Sauvegarder toutes les bases de données :
|
||||
```shell
|
||||
mysqldump --user=mon_user --password=mon_password --all-databases > fichier_destination.sql
|
||||
```
|
||||
Sauvegarder une base de données précise :
|
||||
|
||||
```shell
|
||||
mysqldump --user=mon_user --password=mon_password --databases nom_de_la_base > fichier_destination.sql
|
||||
```
|
||||
Sauvegarder plusieurs bases de données :
|
||||
|
||||
```shell
|
||||
mysqldump --user=mon_user --password=mon_password --databases nom_de_la_base_1 nom_de_la_base_2 > fichier_destination.sql
|
||||
```
|
||||
Sauvegarder une table précise :
|
||||
|
||||
```shell
|
||||
mysqldump --user=mon_user --password=mon_password --databases nom_de_la_base --tables nom_de_la_table > fichier_destination.sql
|
||||
```
|
||||
Sauvegarder plusieurs tables :
|
||||
|
||||
```shell
|
||||
mysqldump --user=mon_user --password=mon_password --databases nom_de_la_base --tables nom_de_la_table_1 nom_de_la_table_2 > fichier_destination.sql
|
||||
```
|
||||
|
||||
# Restaurer
|
||||
|
||||
Restaurer toutes les bases de données :
|
||||
|
||||
```shell
|
||||
mysql --user=mon_user --password=mon_password < fichier_source.sql
|
||||
```
|
||||
Restaurer dans une base de données précise :
|
||||
|
||||
```shell
|
||||
mysql --user=mon_user --password=mon_password nom_de_la_base < fichier_source.sql
|
||||
```
|
14
content/post/notes/proxmox/index.md
Normal file
14
content/post/notes/proxmox/index.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: "Proxmox"
|
||||
date: 2025-05-23T09:12:07+02:00
|
||||
tags:
|
||||
- 100DaysToOffload
|
||||
draft: false
|
||||
author: "Colmaris"
|
||||
toc: true
|
||||
---
|
||||
## Restaurer un container LXC en ligne de comande
|
||||
|
||||
```shell
|
||||
pct restore <vmid> /chemin/vers/le/fichier/dump --storage <nom du stoackage>
|
||||
```
|
33
content/post/notes/tar/index.md
Normal file
33
content/post/notes/tar/index.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: "Tar"
|
||||
date: 2025-03-06T15:12:14+01:00
|
||||
tags:
|
||||
- tar
|
||||
---
|
||||
Compilation de mes notes sur Tar.<!--more-->
|
||||
|
||||
# Compresser
|
||||
|
||||
Pour compresser un fichier ou un répertoire au format `.tar.gz`.
|
||||
|
||||
```shell
|
||||
tar czvf <nom_archive>.tar.gz <nom_rep ou nom_fichier>
|
||||
```
|
||||
|
||||
* `c` : créer une nouvelle archive
|
||||
* `z` : permet d'activer la compression "gzip" pour un taux de compression plus important
|
||||
* `v` : mode verbeux, permet d'afficher dans le détail les fichiers compressés
|
||||
* `f` : utilise le fichier d’archive ou le périphérique <nom_archive>
|
||||
|
||||
# Décompresser
|
||||
|
||||
Pour décompresser un fichier ou un répertoire au format `.tar.gz`.
|
||||
|
||||
```shell
|
||||
tar xzvf <nom_archive>.tar.gz -C <rep_cible>
|
||||
```
|
||||
|
||||
* `x` : décompresse l'archive
|
||||
* `z` : spécifie qu'il s'agit d'une compression au format "gzip"
|
||||
* `v` : mode verbeux, permet d'afficher dans le détail les fichiers compressés
|
||||
* `f` : utilise le fichier d’archive ou le périphérique <nom_archive>
|
152
content/post/notes/traefik/traefik.md
Normal file
152
content/post/notes/traefik/traefik.md
Normal file
|
@ -0,0 +1,152 @@
|
|||
---
|
||||
title: "Traefik"
|
||||
date: 2025-04-09T12:02:34+02:00
|
||||
tags:
|
||||
- 100DaysToOffload
|
||||
draft: false
|
||||
author: "Colmaris"
|
||||
description: "Jour 015/100 du défi 100DaysToOffLoad."
|
||||
toc: true
|
||||
---
|
||||
Compilation d'infos utiles sur Traefik.
|
||||
|
||||
## Fichiers
|
||||
|
||||
Les fichiers de confs se trouvent sur ma [forge]() git.
|
||||
|
||||
## Identifiant de connexion
|
||||
|
||||
L’identifiant de connexion se présente sous la forme d’une ligne de texte à ajouter tel quel dans le fichier `traefik_auth_file`, contenant le nom d’utilisateur et le mot de passe qui sera chiffré avec openssl. Dans le répertoire `/traefik/secrets`.
|
||||
|
||||
```shell
|
||||
openssl passwd -apr1 mon_mot_de_passe
|
||||
$apr1$89eqM5Ro$CxaFELthUKV21DpI3UTQO.
|
||||
```
|
||||
|
||||
Copier ensuite l'identifiant/mot de passe dans le fichier `/traefik/secrets` :
|
||||
|
||||
```shell
|
||||
user:$apr1$89eqM5Ro$CxaFELthUKV21DpI3UTQO.
|
||||
```
|
||||
|
||||
## Configuration TLS
|
||||
|
||||
Dans le répertoire `/traefik/config` ajouter un fichier `tls.yml`. Il s’agit d’une configuration classique, j’utilise les ciphers autorisés dans la configuration par defaut, avec une version de TLS minimum en 1.2 et je force l’utilisation de TLSv1.3.
|
||||
|
||||
```yaml
|
||||
tls:
|
||||
options:
|
||||
default:
|
||||
minVersion: VersionTLS12
|
||||
sniStrict: true
|
||||
cipherSuites:
|
||||
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 # TLS 1.2
|
||||
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 # TLS 1.2
|
||||
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 # TLS 1.2
|
||||
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 # TLS 1.2
|
||||
- TLS_AES_256_GCM_SHA384 # TLS 1.3
|
||||
- TLS_CHACHA20_POLY1305_SHA256 # TLS 1.3
|
||||
- TLS_FALLBACK_SCSV # TLS FALLBACK
|
||||
curvePreferences:
|
||||
- secp521r1
|
||||
- secp384r1
|
||||
- X25519
|
||||
- CurveP521
|
||||
- CurveP384
|
||||
- CurveP256
|
||||
modern:
|
||||
minVersion: VersionTLS13
|
||||
```
|
||||
|
||||
## Les middlewares
|
||||
|
||||
Par souci de compréhension j'utilise un fichier par middleware. Ils sont placés dans le dossier `/traefik/config/nom-middleware.yml`.
|
||||
|
||||
### Headers et HSTS
|
||||
|
||||
Nom du fichier : config.yml
|
||||
|
||||
```yaml
|
||||
hsts-headers:
|
||||
headers:
|
||||
frameDeny: true
|
||||
browserXssFilter: true
|
||||
contentTypeNosniff: true
|
||||
stsIncludeSubdomains: true
|
||||
stsPreload: true
|
||||
stsSeconds: 31536000
|
||||
forceStsHeader: true
|
||||
```
|
||||
|
||||
### Compression
|
||||
|
||||
Compression en GZIP, nom du fichier: compression.yml.
|
||||
|
||||
```yaml
|
||||
http:
|
||||
middlewares:
|
||||
compression:
|
||||
compress:
|
||||
excludedContentTypes:
|
||||
- "text/event-stream"
|
||||
```
|
||||
|
||||
## Docker compose commenté
|
||||
|
||||
```yaml
|
||||
networks:
|
||||
traefik:
|
||||
external: true
|
||||
|
||||
services:
|
||||
traefik:
|
||||
image: traefik:banon
|
||||
restart: unless-stopped
|
||||
container_name: traefik
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
labels:
|
||||
- traefik.enable=true # J'active traefik
|
||||
- traefik.docker.network=traefik # j'indique le réseau pour l'exposition du conteneur
|
||||
- traefik.http.middlewares.admin-auth.basicauth.usersfile=/secrets/traefik_auth_file # fichier contenant l'auhentification pour l'accès au dashboard
|
||||
- traefik.http.routers.traefik.rule=Host(`traffic.${DOMAIN}`) # url d'accès
|
||||
- traefik.http.routers.traefik.entrypoints=https # port d'écoute utilisé
|
||||
- traefik.http.routers.traefik.tls=true # chiffrage
|
||||
- traefik.http.routers.traefik.service=api@internal # service propre à traefik pour le dashboard
|
||||
- traefik.http.routers.traefik.tls.certresolver=le # Let's encrypt comme resolveur de certificat
|
||||
- traefik.http.routers.traefik.middlewares=admin-auth # activation de l'authentification via le fichier défini plus haut
|
||||
- traefik.http.services.traefik.loadbalancer.server.port=8080 # port d'écoute du dashbord non exposé
|
||||
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro # écoute de l'api docker
|
||||
- /mnt/nas/voljin/volumes/traefik:/certificates # stockage des certificats
|
||||
- ./secrets:/secrets:ro # stockage des mots de passes
|
||||
- ./config:/config:ro # configuration dynamique
|
||||
- ./logs:/logs # enregistrement des logs.
|
||||
command:
|
||||
# ------------------------------------------- providers Docker
|
||||
- --providers.docker
|
||||
- --providers.docker.exposedbydefault=false
|
||||
# ------------------------------------------- Providers Fichier
|
||||
- --providers.file.directory=/config/
|
||||
- --providers.file.watch=true
|
||||
# ------------------------------------------- Ports
|
||||
- --entrypoints.http.address=:80
|
||||
- --entrypoints.https.address=:443
|
||||
# ------------------------------------------- Redirection vers https
|
||||
- --entrypoints.http.http.redirections.entrypoint.to=https
|
||||
- --entrypoints.http.http.redirections.entrypoint.scheme=https
|
||||
# ------------------------------------------- Configuration SSL
|
||||
- --certificatesresolvers.le.acme.email=${TRAEFIKEMAIL}
|
||||
- --certificatesresolvers.le.acme.storage=/certificates/acme.json
|
||||
- --certificatesresolvers.le.acme.tlschallenge=true
|
||||
# ------------------------------------------- Configuration traefik
|
||||
- --global.sendanonymoususage=false
|
||||
- --accesslog=true
|
||||
- --log.level=INFO
|
||||
- --log.filePath=/logs/traefik.log
|
||||
- --api
|
||||
networks:
|
||||
- traefik
|
||||
```
|
81
content/post/notes/update-nextcloud/index.md
Normal file
81
content/post/notes/update-nextcloud/index.md
Normal file
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
title: "Nextcloud"
|
||||
date: 2025-03-04T10:08:29+01:00
|
||||
tags:
|
||||
- adminsys
|
||||
- nextcloud
|
||||
---
|
||||
Compilation d'infos utiles pour mon instance Nextcloud.<!--more-->
|
||||
|
||||
## Mise à jour via le terminal.
|
||||
|
||||
Se placer dans le répertoire Nextcloud `/var/www/nextcloud` et taper la commande:
|
||||
|
||||
```shell
|
||||
sudo -u www-data php updater/updater.phar
|
||||
```
|
||||
|
||||
A cet instant le processus est lancé.
|
||||
|
||||

|
||||
|
||||
La procédure achevée, le programme demande s'il doit exécuter la commande `occ upgrade` pour réaliser la mise à jours des applications tierces.
|
||||
|
||||
Cela finit avec le choix de laisser le mode maintenance activé ou non.
|
||||
|
||||
## Déplacer le dossier data
|
||||
|
||||
__1. Arrêt du serveur web.__
|
||||
|
||||
```shell
|
||||
service stop nginx #pour nginx
|
||||
```
|
||||
Installer le nouveau disque dur, le partitionner, le formater et le monter. Pour le partitionner, j’ai utilisé `cfdisk`.
|
||||
|
||||
__2. Le formatage.__
|
||||
|
||||
```shell
|
||||
mkfs.ext4 /dev/sdb
|
||||
```
|
||||
|
||||
__3. Montage au système.__
|
||||
|
||||
```shell
|
||||
mkdir /mnt/datacloud
|
||||
mount /dev/sdb1 /mnt/datacloud
|
||||
```
|
||||
|
||||
Afin que le montage soit permanent il faut éditer le fichier `/etc/fstab` pour ajouter cette ligne en fin de fichier :
|
||||
|
||||
```shell
|
||||
/dev/sdb1 /mnt/datacloud ext4 defaults 0 0
|
||||
```
|
||||
|
||||
__4. Migration des données.__
|
||||
|
||||
```shell
|
||||
mv /var/www/nextcloud/data/ /mnt/datacloud/data
|
||||
```
|
||||
Cela prendra plus ou moins de temps en fonction de la taille du dossier. Mise en place des droits, sans cela les données ne seront pas visible depuis l’interface Web. Il faut donner les droits à l’utilisateur qui gère le service web sur le serveur, sous Debian il s’agit de « www-data ».
|
||||
|
||||
```shell
|
||||
chown -R www-data:www-data /mnt/datacloud/data/
|
||||
```
|
||||
|
||||
__5. Modification de la configuration de nextcloud.__
|
||||
|
||||
```shell
|
||||
sudo nano /var/www/nextcloud/config/config.php
|
||||
```
|
||||
|
||||
Chercher la ligne `datadirectory` et modifier le champs avec le nouveau chemin.
|
||||
|
||||
```shell
|
||||
'datadirectory' => '/mnt/datacloud/data',
|
||||
```
|
||||
|
||||
Pour terminer, démarrage du serveur web :
|
||||
|
||||
```shell
|
||||
sudo systemctl start nginx
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue