What is the best way for me to back up iocage jails?

ninjai

Explorer
Joined
Apr 6, 2015
Messages
98
I've read so many methods. iocage export was one, but drawbacks seem to be that in some cases it claimed that the jail was successfully exported, but due to a bug it could not be restored. Scary. You also need to stop and start the jail for this. Then I read about ZFS clones, but to me it sounds like to use snapshots as a backup I need to be snaping to another ZFS pool, and it can't be conventional storage like an external HD or generic network share.

Quite simply, if I made a script to shut down the jail (iocage stop jailname) then copy the contents of the directory (rsync av /mnt/iocage/jails/jailname /some/other/not/zfs/storage) would that be better?

I'm a home user, simply want a clone of my jails that I can role back if needed. Backups will be about once per week. No option of second ZFS-based NAS.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Snapshots and replication... Depends on exactly what level of data security you're after, but snapshots mean it isn't strictly necessary to stop the jail and you can roll back to any snapshot point in time, then with replication (localhost can be the target to a different pool/dataset), you can cover against an entirely lost primary jails pool.
 

ninjai

Explorer
Joined
Apr 6, 2015
Messages
98
Is it also possible for me to snapshot sections of datasets instead of the whole dataset? Like if I have a dataset called "videos" and I have 2 folders in there "video edits" and "video cache", can I do a snapshot of just videos/video edits, or does it need to be the whole thing?
 

Mlovelace

Guru
Joined
Aug 19, 2014
Messages
1,111
Is it also possible for me to snapshot sections of datasets instead of the whole dataset? Like if I have a dataset called "videos" and I have 2 folders in there "video edits" and "video cache", can I do a snapshot of just videos/video edits, or does it need to be the whole thing?
Snapshots are at the dataset level, so if 'vidoe edits' was a nested dataset inside 'videos' you could snap the 'video edits' independently.
 

ninjai

Explorer
Joined
Apr 6, 2015
Messages
98
A few more questions:

If I was to roll my backup setup to snapshots instead of rsnapshot:

1. Can I do excludes? Like will my iocage jails mount points be backed up in the snapshot too (therefor creating a large backup)
2. Do I need to make these snapshots recursive?
3. Can I do a day of the week, for example sunday, and create a recursive snap to a seocndary pool, then delete the snap from primary storage and all the data will still be on the secondary pool?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
1. Snapshots are the whole dataset. iocage is a dataset and each jail is its own child dataset (actually it's even a bit more complex than that, but I guess you get the point)... see point 2. Mount points within the jail datasets are not traversed in a snapshot.

2. It's not compulsory and depends on how you want things to work. If you don't want all children, then you can't do recursive and need to specify each child in a snapshot.

3. Replication jobs don't work like that, but you can probably do it with manual scripts (look at posts from @fracai for some starters)... I'm not convinced it's a good idea, since incrementally sending snapshots (as replication jobs is doing) is a good way to keep the backup updated, but without the intermediate snapshots being present on both, you will end up needing to send entire/full snapshots every time. Depends on how busy you're prepared to let your server be doing the backups.

I think you're probably better off using replication jobs with relatively short snapshot lifetime (like 7 days or fewer), but don't have the replication job clear the expired snapshots on the backup... then use one of @fracai 's scripts to prune the ones you con't need which are older than a week on the backup pool.
 
Last edited:
Top