Question about ZFS, Snapshots and Replica

trebong

Dabbler
Joined
Jan 9, 2022
Messages
25
=== GERMAN VERSION BELOW ===

Hello community,

My pool is full and I need to tidy it up. Simply deleting some data is one thing, but only feasible to a certain extent. Where I can still get quite a lot out are my countless snapshots. But in my experience, simply deleting them is not trivial. I've already ruined my backups in the process. - But first things first.

I have the following structure:
  • A disk with a pool (no, no redundancy - yes, I know, it's a big risk. There's no other way at the moment ...)
  • There are various datasets in the pool.
  • My TrueNAS creates snapshots of the datasets every day.
  • Depending on the dataset, the snapshots are kept for a certain period of time (7 days, 30 days, 3 months, etc.) and then deleted automatically.
  • In addition, an external disc with a pool for backups is connected at irregular intervals.
  • A backup script recognises this external disc, creates a separate snapshot of the datasets and then creates an incremental replica on the external disc. (Via zfs send ... | zfs receive ....)
  • The snapshots created by the backup script do not have an automatic "expiry date" and accumulate over time, taking up a lot of space.
I would like to delete some of the very old snapshots generated by the backup script on the internal disc.

In principle, I would also like to delete the completely outdated snapshots on the external backup disc.

Basically, I know how to delete the snapshots (zfs destroy ... ).

My problem some time ago was that I broke something by manually deleting the snapshots created by script. Unfortunately, I can't remember the exact details. Somehow the connection between the internal pool and the backup pool suffered. The replica in the backup script kept crashing. At some point I found out that the problem was the missing snapshots, which one expected but the other no longer had.

In the end, I had to flatten the entire backup pool and redo it. Then everything was backed up again from scratch. - That can't be the solution.

Do you have any tips for me on how I can clean up the snapshots without causing the replica as such to become inconsistent?

Thank you and best regards
trebong


************************

Hallo Community,

mein Pool läuft voll und ich muss aufräumen. Einfach ein paar Daten löschen ist das eine, aber nur in gewissem Rahmen machbar. Wo noch recht viel raus zu holen geht, sind meine unzähligen Snapshots. Aber die einfach weg zu löschen, ist nach meiner Erfahrung nicht ganz trivial. Ich habe mir dabei schon mal meine Backups zerschossen. - aber der Reihe nach.

Folgende Struktur habe ich:
  • Eine Disk mit einem Pool (nein, keine Redundanz - ja, ich weiß, ist ein großes Risiko. Geht gerade nicht anders ...)
  • In dem Pool gibt es diverse Datasets.
  • Mein TrueNAS erzeugt jeden Tag Snapshots von den Datasets.
  • Die Snapshots werden je nach Dataset einen bestimmten Zeitraum (7 Tage, 30 Tage, 3 Monate, usw.) aufgehoben und dann automatisch gelöscht.
  • Zusätzlich wird regelmäßig-unregelmäßig eine externe Disk mit Pool für Backups angeschlossen.
  • Ein Backup-Script erkennt diese externe Disk, erzeugt einen separaten Snapshot von den Datasets und erstellt dann davon auf der externen Disk eine inkrementelle Replik. (Via zfs send ... | zfs receive ....)
  • Die per Backup-Script erstellten Snapshots haben kein automatisches "Verfallsdatum" und sammeln sich mit der Zeit an und verbrauchen viel Platz.
Einige der per Backup-Script generierten ur-alten Snapshots möchte ich auf der internen Disk löschen.
Prinzipiell möchte ich auch die völlig veralteten Snapshots auf der externen Backup-Disk löschen.

So vom Grundprinzip weiß ich, wie ich die Snapshots lösche (zfs destroy ... ).

Mein Problem vor einiger Zeit war, dass ich durch das manuelle Löschen der per Script erstellten Snapshots was kaputt gemacht habe. Genaues weiß ich leider nicht mehr. Irgendwie hat die Verbindung zwischen internem Pool und Backup-Pool gelitten. Die Replik im Backup-Script brach dabei ständig ab. Irgendwann bekam ich heraus, dass das Problem die fehlenden Snapshots waren, die der eine erwartete, aber der andere gar nicht mehr hatte.

Ich musste am Ende den ganzen Backup-Pool platt und neu machen. Danach wurde noch mal alles von Vorne gesichert. - Das kann ja auch nicht die Lösung sein.

Habt ihr Tipps für mich, wie ich die Snapshots aufräumen kann, ohne die Replik als solche in eine Inkonsistenz zu stürzen?

Habt Dank und viele Grüße
trebong
 
Joined
Oct 22, 2019
Messages
3,641
Do you have any tips for me on how I can clean up the snapshots without causing the replica as such to become inconsistent?
If these "backup" snapshots and incremental replications are infrequent, you could use the "hold" feature to ensure there will always be a common base snapshot between the source and destination.

This can be done manually, or incorporated into a script. (A combination of listing, grepping, sorting, and xargs can automated this.)

The same is true for the "release" feature. However, you might decide that you'll only "release" a snapshot's protection manually, since it will slow things down and lessen the likelihood of destroying something too hastily.


EDIT: Noticed you're on SCALE. There should be a "Hold" checkbox when viewing a snapshot.
 
Top