HrWGoAgain: Add Drives

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
Hey guys,

did some research and seems like I can't just add drives to my 5-drive ZFS pool. Okay I will destroy it, add drives and create the pool again, then copy the data again (this TrueNAS Core build is a backup server). The question is: can I easily restore pool configurations? Like datasets, all the fine tunings and etc.. Is it all saved in configuration backup?

Thanks so much!
 
Joined
Oct 22, 2019
Messages
3,641
The question is: can I easily restore pool configurations? Like datasets, all the fine tunings and etc.. Is it all saved in configuration backup?
No. A pool, its layout, and its data is unrelated to the config file.

The most streamline way to restore a pool is to restore from a backup pool using ZFS send/recv (i.e, "replication").
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
The most streamline way to restore a pool is to restore from a backup pool using ZFS send/recv (i.e, "replication").

Thank you! But this backup pool has to have all those terabytes of data in it, no way to export/import just the pool layout and SMB/Time Machine settings etc, right?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You can keep all the SMB settings by stopping and disabling the SMB service, then export and destroy the pool. You will have to create all the datasets in the new pool but that can be semi automated even if you are not familiar with scripting. Take the output of zfs list (copy&paste from ssh session) and use the editor of choice to produce dozens, hundreds (?) ... of zfs create statements. Then copy&paste these back into the ssh window.
A similar procedure can be created for ACLs. AFAIK there are commands that output ACLs in a format that can later be reapplied another or a new dataset.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
If you use pool level ZFS Send to create the backup, it will contain the the entire dataset structure including all the ACLs and extended attributes. Then, a reverse ZFS Receive to an empty pool will restore the whole thing. The key thing to understand, is that their is a difference between pool structure, (aka RAID-Zx vDevs), and dataset structure, (aka file systems for sharing).

Note that the output of a ZFS Send is just an I/O stream that can be saved in a file, or piped directly to ZFS Receive for immediate re-creation of the pool on other media.


I do wish there was a ZFS script to capture the exact dataset layout, along with pool & dataset attributes. I ended up writing something primitive for my own recovery procedures. (My backups are not ZFS Send & Receive... so any restore would only restore data, not the pool or dataset attributes.) But, any such good script would have to check for lots of things, like new, active attributes that don't exist in the source info.
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
Thank you guys thank you everyone! I think I'll just delete all the contents preserving the structure and then send/export with all the methods mentioned. Thanks again! )))
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
Hey guys! Just to recap -- I want to clone a pool with all the datasets and its settings intact. I emptied the directories because in this case I care about the keeping the structure/datasets, not the data. The pool's name is "Pool". Then I inserted a USB stick and created a pool on it titled "usb-pool". Then I type this in CLI:

zfs send -R Pool | zfs recv usb-pool

And TrueNAS responds:

Error: Unsupported flag with filesystem or bookmark.
cannot receive: failed to read from stream


Could you guys please help me with the correct syntax? I don't have any snapshots, just want to clone a pool"without files" ))
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You can only clone snapshots to ensure that a consistent state is cloned and nobody is changing the pool while the cloning is going on.
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
You can only clone snapshots to ensure that a consistent state is cloned and nobody is changing the pool while the cloning is going on.
All so I have to make a snapshot of an entire pool, then send/recv this snapshot to another pool and then I can "clone" back from that another pool to a new one? My situation is: I have a 5-disk pool (titled "Pool") that I want to expand with 2 extra drives. AFAIK I can't just add drives to the pool, so I have to destroy my 5-disk pool and create a new 7-disk pool with the same datasets and settings as my current 5-disk pool has. Could you please help me with CLI commands? Thank you so much!
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
Oh I think I managed to do a -R snapshot and sent it to USB pool, will try to replicate to HDD, Thanks!!
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
So I recreated datasets with -R snapshot but seems like I have to re-create SMB shares and Rsync modules. Duh...
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
These are saved in the TN configuration database and not in the ZFS pool, so ... yes.
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
These are saved in the TN configuration database and not in the ZFS pool, so ... yes.
I only snapshotted and exported/disconnected the pool, then created a new pool and "zfs sent" all datasets snapshots (-R) from USB to a new pool, I didn't reinstall TN, boot-pool (SSD) remained unchanged )
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Does the new pool now that it is re-imported have the same name the old one had? So all the dataset paths like /mnt/<pool>/some/data/set are identical? Then the shares and everything else should continue to work.

If you changed the pool name, they don't.
 

throttlenerd

Dabbler
Joined
Jan 12, 2024
Messages
16
Does the new pool now that it is re-imported have the same name the old one had? So all the dataset paths like /mnt/<pool>/some/data/set are identical? Then the shares and everything else should continue to work.

If you changed the pool name, they don't.
No, I didn't change the name, it was "Pool" and now it's "Pool" too.. Ah anyway I think I won't have to do it again, this backup box won't fit extra drives )) Thank you!
 
Top