Backup jail for storage expansion

Status
Not open for further replies.

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
Hello everyone,

I'm planning on expanding my current storage (4x4TB raidz2 to 6x4TB raidz2) very soon. I fully understand that I will have to destroy my pool and start from scratch and am ok with that since I have a backup solution to store all my data during the transition.

However, I'd like to make this process as easy as possible (duh) and I am wondering what the exact steps would be to achieve this goal.

So my questions are :
  1. Is the config backup useful in any way for this use case (destroying / creating new pool) ? Can it be used to restore the storage "layout" (I want to keep the way I organized my datasets, just expand their size) ? Basically I'm not sure what is stored in the config backup and what it can be used for, other than recovering from a failed boot drive...
  2. How can I backup my jails to restore them once the new pool is created ? The data is not a problem as it is just a matter of copying files from the backup to the new pool. But I have some jails that I spent time to set up and I would like to transfer them "as-is". I found this topic but am not sure that it's the right way to do it as it's kind of a hack.
All in all, my questions could be summed up like this : "What are the steps to expand my storage (4x4TB raidz2 to 6x4TB raidz2) while keeping my configuration and my jails intact ?". I'm sure this use case has been encountered before, but I couldn't find any recent complete tutorial explaining this.

I was thinking of simulating the whole process with a VM at some point anyway (better be safe than sorry), but I would really appreciate a better understanding of all this from you guys.

Thanks for the help
 
Joined
Jan 7, 2015
Messages
1,155
@depasseg Wrote THIS up. Ive used it, it works. Then there is THIS. Particularly see the part that @Dusan added. Both have great info that works like a dream. You might want to use a combination of both and or leave out parts that dont pertain to you. Then finally HERE is my original post when I was migrating to new/larger pool a year or two ago very similar albeit a bit different than what you are want to do..

Between those three threads, all the info you need is there.
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
First of all, thanks for your answer.

I went through all the links you gave, but I don't think they really apply to my case (maybe I'm wrong). I should have mentioned that my "backup solution" for my data is actually a pair of external drives, on which I sync the data from my NAS periodically. Therefore, I don't have enough drives to do the "zfs send / receive" thing with two pools on the same machine, nor do I have a second FreeNAS / ZSF machine : the drives of my actual pool will be part of the new one (I'm simply adding two drives to my pool), hence the mandatory destruction / creation of a new pool.

That's why I initially went with the topic I mentioned in the first post : it provided a solution to "backup" the jails by obtaining a simple file that you could apparently move, store, and import anywhere.

Regarding the details I provided, would you say that the methods you gave could apply to my situation ? The "zfs send / receive" seems like the best way to do it to me, but I don't see how I'm supposed to do without a second FreeNAS machine / pool.
 
Joined
Jan 7, 2015
Messages
1,155
Jails and such are generally pretty small. I think it might be hard for a jails dataset to be larger than a few hundred gigabytes.

Do you have any hard drive large enough to temporarily store this jail data that is not USB in nature? If so, put it in the machine and set up a single drive stripe (raid 0), follow the procedure to move jails and system dataset to a different 2nd dataset (this single drive stripe). Make sure you have a config backup after you do this (and before too). Make sure the rest of the data is sufficiently backed up and when you are satisfied it is, detach and destroy your pool(s), but make absolutely sure you have everything, and leave the temp pool alone!!!, and recreate your pool(s) to your satisfaction, leaving the single stripe holding the jail data, then begin by creating your new pool, then by importing the jails back off the temporary pool, by basically reversing @depasseg instructions. Then once they are all starting and everything seems normal, you named the pools the same and such. Copy your other data back over. Finally you might (and possibly might not if everything is named the same and such) need to restore the config.

I typed this fast, i might have missed something. If you have further questions or something doesnt make sense, dont hesitate to ask. I have done this a few times for myself and others, and all times it has worked very slick.

Good luck!! Dont sweat it!
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
I didn't think of using a USB key as a backup device, since I didn't even know that I could use one to set up a pool. Sure my jails aren't that heavy (I keep all of my jails' data out of them by using storages, like for my Plex server metadata). With this solution in mind and by following your other links, I should be able to make this work. I'm currently trying to simulate this in a VM until my drives are delivered (actually I'm pulling my hair out with jail issues inside the VM, but that's another story). I'll keep the thread updated as I make progress (either with the VM or with my real setup), but that should take a while (other stuff to deal with).

In the meantime : thanks again !

Edit : Dammit ! I don't know where I read about a USB key (must be pretty tired). Unfortunately no : I don't have any drive that is not USB in nature... isn't there a way to use a USB key / drive to do it ?
 
Joined
Jul 10, 2016
Messages
521
You could just send your whole jails dataset to a binary file using zfs send, and back it up on your external back up storage, e.g.(assuming your pool is called tank and your jails dataset is /mnt/tank/jails):

Code:
zfs snapshot -r tank/jails@relocate
zfs send -R tank/jails@relocate > /mnt/tank/path/to/some_file_name

Save this file to your backup storage. Then, after you've freshly rebuild your pool, restore that file in the same location and use zfs receive to restore the dataset.
Code:
zfs receive -v tank/jails < /mnt/tank/path/to/some_file_name

Here are some references to read up on:
FreeBSD zfs administration
Fun with ZFS send and receive
 
Last edited:
Joined
Jan 7, 2015
Messages
1,155
Absolutely. It must also be wiped out and formatted to a ZFS stripe however. This I havent done, but in theory it should work. Why dont you PM me your address and ill send you a 1TB or 1.5TB hard drive. Would that solve the problem? I have no less than 15 of them sitting doing nothing.
 
Joined
Jan 7, 2015
Messages
1,155
Learn something new everyday. I did not know you could replicate a dataset to a single file. Guess its not really a ton different than a drive.. Good stuff!
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
Nice @Jurgen Segaert, I didn't know that you could send a dataset to a binary file like this either. That should do the trick perfectly.

That's so nice of you @John Digital !! But I really couldn't ask you that, that's just too embarrassing >< (even though they "sit doing nothing"). I'll better try the "replicate to a single file" solution, which should save everyone much trouble ;) But I really appreciate your offer =)

I'll keep you guys updated.
 
Joined
Jan 7, 2015
Messages
1,155
Do onto others little brother.. Let me know if you change your mind!!

Good luck!
 
Joined
Jul 10, 2016
Messages
521
I ran a test in a VM and I noticed I forgot the -R flag in the zfs send command. I corrected the original posting. :oops:
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
I ran a test myself in a VM but I get the following error when trying to restore the backup :
cannot receive: invalid name

All I did was a new FreeNAS install, install a plugin, and do all the commands you provided.

Do you have any lead ?

Edit : Needless to say that I adapted the names and paths to match mine...
 
Last edited:
Joined
Jul 10, 2016
Messages
521
Does the error occur on the zfs receive command? Can you provide some more information, such as the exact commands you're running, the output of zfs list and ls -al showing the directory where your backup file resides.
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
Sure, I've issued the following commands :
zfs snapshot -r Storage/jails@relocate
zfs send -R Storage/jails@relocate > /mnt/Storage/data/file
zfs receive -v /mnt/Storage/jails < /mnt/Storage/data/file


The error indeed occurs on the zfs receive command, and here's the complementary information :

[root@freenas ~]# zfs list
NAME USED AVAIL REFER MOUNTPOINT
Storage 1.89G 3.83T 25.4K /mnt/Storage
Storage/.system 5.26M 3.83T 28.4K legacy
Storage/.system/configs-a75e42d926e4418a8e21357ce29c963c 25.4K 3.83T 25.4K legacy
Storage/.system/cores 678K 3.83T 678K legacy
Storage/.system/rrd-a75e42d926e4418a8e21357ce29c963c 25.4K 3.83T 25.4K legacy
Storage/.system/samba4 97.9K 3.83T 97.9K legacy
Storage/.system/syslog-a75e42d926e4418a8e21357ce29c963c 4.42M 3.83T 4.42M legacy
Storage/data 1.88G 3.83T 1.88G /mnt/Storage/data
freenas-boot 631M 14.8G 31K none
freenas-boot/ROOT 624M 14.8G 25K none
freenas-boot/ROOT/Initial-Install 1K 14.8G 620M legacy
freenas-boot/ROOT/default 624M 14.8G 621M legacy
freenas-boot/grub 6.33M 14.8G 6.33M legacy



[root@freenas ~]# ls -la /mnt/Storage/data/
total 3948507
drwxrwxr-x+ 2 myUsername myUsername 5 Mar 14 14:50
drwxr-xr-x 3 root wheel 3 Mar 14 14:51 ..
-rw-r--r-- 1 root wheel 0 Mar 13 22:49 .windows
-rwxrwxr-x+ 1 root myUsername 959530464 Mar 14 14:50 file
 
Joined
Jul 10, 2016
Messages
521
Do this:
zfs receive -v Storage/jails < /mnt/Storage/data/file
instead of this:
zfs receive -v /mnt/Storage/jails < /mnt/Storage/data/file

Great idea to practice in a VM first!
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
Nice ! It works ! I actually found it weird that there is two different syntax for sending and receiving, but you seemed sure of it and said that you tested in a VM so I didn't think this could be it...

I still have a bonus question though :

So my jails are almost all "non-plugin based", and those seem to be working fine after the receive and a reboot (though I'll do some more testing with cases closer to my real setup to be absolutely sure). But I still have one plugin based jail and although the jail works, the plugin doesn't seem to work : it's the transmission plugin and I can't access the GUI and the installed plugins list is empty.

Do you have any idea about that ? I don't mind not using plugins for my "important" jails as I can update them more freely compared to plugins and all that stuff (read many topics about that). But a jail is like 10x heavier than a plugin (correct me if I'm wrong). So for a simple thing like transmission, which isn't updated that often btw, I prefer to use the plugin. Sure this example is pretty bad since I could simply install and configure it again in a few minutes, but I like to understand how things work and I'd like to be able to backup my plugins as well if I happen to use more of them (and more complex) in the future.
 
Last edited:
Joined
Jul 10, 2016
Messages
521
I updated the original posting for people that reference this thread in the future. I'm not that familiar with the PBI based plugins. If you haven't tried this already, I would stop the jail, (re)import the FN configuration file and start it again.
 

Scentle5S

Explorer
Joined
Sep 9, 2016
Messages
74
I suppose the FN configuration file was indeed the solution. In my first scenario, I actually never imported the file (I was only interested about the jails at first). During some other tests I just did, I imported the configuration file before receiving the jails, and the plugin works just fine. So my guess is that the configuration file is "optional" when it comes to jails (there might just miss the storages and stuff like that), but mandatory when it comes to PBI based plugins.

Anyway, everything seems to work perfectly. Can't wait to do the whole thing on my real setup once I get my drives ! I will keep the thread updated once it is done, for others that may pass by in the future and would like to know how it went. But nothing should go wrong now.

Thanks again to you two guys for your help, you saved me from lots of pain with this project ! ;)
 
Status
Not open for further replies.
Top