tech:notes_sauvegardes_backup_avec_restic
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:notes_sauvegardes_backup_avec_restic [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:notes_sauvegardes_backup_avec_restic [2025/12/04 18:19] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| {{tag> | {{tag> | ||
| - | = Notes sauvegardes backup avec Restic | + | # Notes sauvegardes backup avec Restic |
| Restic - L’excellent outil de sauvegarde de fichiers | Restic - L’excellent outil de sauvegarde de fichiers | ||
| Ligne 14: | Ligne 15: | ||
| Exemple avec rclone | Exemple avec rclone | ||
| - | < | + | ~~~bash |
| rclone serve restic --addr localhost: | rclone serve restic --addr localhost: | ||
| - | </ | + | ~~~ |
| - | < | + | ~~~bash |
| export RESTIC_REPOSITORY=' | export RESTIC_REPOSITORY=' | ||
| export RESTIC_PASSWORD=Password123 | export RESTIC_PASSWORD=Password123 | ||
| - | </ | + | ~~~ |
| - | < | + | ~~~bash |
| + | restic init | ||
| restic snapshots | restic snapshots | ||
| restic stats | restic stats | ||
| restic find --tag Plop ' | restic find --tag Plop ' | ||
| restic backup /data/ | restic backup /data/ | ||
| + | find ~/bin/ -maxdepth 1 -type f -print0 | restic backup --tag plop --files-from-raw=/ | ||
| restic ls -l latest | restic ls -l latest | ||
| - | </ | + | ~~~ |
| - | < | + | ~~~bash |
| mkdir mnt | mkdir mnt | ||
| restic mount mnt/ & | restic mount mnt/ & | ||
| ls -l ~/ | ls -l ~/ | ||
| - | </ | + | ~~~ |
| - | <code -> | + | ~~~ |
| $ ls mnt/ | $ ls mnt/ | ||
| hosts ids snapshots | hosts ids snapshots | ||
| - | </ | + | ~~~ |
| Maintenance | Maintenance | ||
| - | < | + | ~~~bash |
| - | restic check | + | restic check --read-data |
| restic prune | restic prune | ||
| Ligne 50: | Ligne 53: | ||
| restic migrate upgrade_repo_v2 | restic migrate upgrade_repo_v2 | ||
| restic migrate | restic migrate | ||
| - | </ | + | ~~~ |
| Remove snapshot | Remove snapshot | ||
| - | < | + | ~~~bash |
| restic snapshots | restic snapshots | ||
| Ligne 61: | Ligne 64: | ||
| restic prune | restic prune | ||
| - | </ | + | ~~~ |
| + | |||
| + | ### Tailles des snapshots | ||
| + | |||
| + | A partir de la version 0.17 | ||
| + | ~~~bash | ||
| + | restic snapshots --json add5377d | jq | ||
| + | ~~~ | ||
| + | |||
| + | Sinon | ||
| + | ~~~ | ||
| + | # Affiche la taille restant après effacement | ||
| + | $ restic forget --dry-run --prune add5377d | grep remaining | ||
| + | remaining: | ||
| + | unused size after prune: 0 B (0.00% of remaining size) | ||
| + | |||
| + | $ restic stats add5377d | grep -i size | ||
| + | Stats in restore-size mode: | ||
| + | Total Size: 31.640 GiB | ||
| + | |||
| + | $ restic stats --mode raw-data add5377d | grep -i size | ||
| + | Total Uncompressed Size: 9.152 GiB | ||
| + | Total Size: 8.235 GiB | ||
| + | |||
| + | $ rclone size e_nas: | ||
| + | Total objects: 589 (589) | ||
| + | Total size: 8.598 GiB (9232005166 Byte) | ||
| + | |||
| + | $ rclone size NAS_FTP: | ||
| + | Total objects: 589 (589) | ||
| + | Total size: 8.600 GiB (9234283006 Byte) | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | $ restic forget --dry-run --prune $(restic snapshots --tag blob | awk '/ | ||
| + | remaining: | ||
| + | unused size after prune: 0 B (0.00% of remaining size) | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Diff entre deux snapshots | ||
| + | ~~~bash | ||
| + | restic snapshots --latest 2 --tag blob | grep /Work$ | ||
| + | restic diff -v f462cfae a230e52f | ||
| + | ~~~ | ||
| + | |||
| + | Différences de tailles entre deux snapshots | ||
| + | ~~~ | ||
| + | $ restic diff f462cfae a230e52f | egrep " | ||
| + | Added: | ||
| + | Removed: 0 B | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ----------- | ||
| + | |||
| + | '' | ||
| + | ~~~bash | ||
| + | #! /bin/bash | ||
| + | |||
| + | set -euo pipefail | ||
| + | |||
| + | # export RESTIC_REPOSITORY=' | ||
| + | # export RESTIC_PASSWORD=P@ssw0rd | ||
| + | |||
| + | # shellcheck source=/ | ||
| + | source ~/ | ||
| + | |||
| + | do_rclone_listen() { | ||
| + | rclone serve restic --addr localhost: | ||
| + | } | ||
| + | |||
| + | do_backup() { | ||
| + | restic backup --tag code ~/code/ | ||
| + | restic backup --tag code ~/*.env | ||
| + | restic backup --tag blob ~/Work/ | ||
| + | restic backup --tag tools ~/go/bin/ | ||
| + | restic backup --exclude=' | ||
| + | find ~/bin/ -maxdepth 1 -type f -print0 | restic backup --tag script --files-from-raw=/ | ||
| + | } | ||
| + | |||
| + | do_post_backup() { | ||
| + | restic prune | ||
| + | } | ||
| + | |||
| + | main() { | ||
| + | do_rclone_listen & | ||
| + | sleep 1 | ||
| + | do_backup | ||
| + | do_post_backup | ||
| + | killall rclone | ||
| + | echo OK | ||
| + | } | ||
| + | |||
| + | main | ||
| + | ~~~ | ||
tech/notes_sauvegardes_backup_avec_restic.1742825205.txt.gz · Dernière modification : de 127.0.0.1
