ZFS Mirror/backup to disk with smaller capacity

I have a running Freebsd system with a 500 gb hard drive. The storage it uses is about 150-200 GB though.

Is it possible to replicate the contents of the system on another drive with storage capacity of 300 GB? So I can occasionally connect it to the system and it serves as backup in case my running hardrive goes bust some day.

What would be the best way to go about it if it's possible?

PS: Never dealt with Zfs mirrors so. Plus running drive is GELI encrypted
 
You could use zfs-send()/zfs-receive() or alternatively dump()/restore(). The latter is filesystem agnostic.

You can send a zfs stream over a ssh session, i.e.
Code:
doas zfs snapshot zroot/something@snapshot
doas zfs send zroot/something@snapshot | ssh remoteserver doas zfs recv zroot/something_different

Replace doas with sudo or whatever floats your boat. This also works with incremental snapshots.

If you do cross the 300GB, you'll have some issues though. It probably is not a good idea to backup to a server with less capacity than the original system, you are backing up. Particularly, if you want to do incremental backups.
 
Also depends on whether the primary system already has compression on. If not and if the files are compressible then the backup disk lasts longer if you turn on compression on the backup.

A stupid trick against overflow would be to create a 200 GB file filled with junk and exclude it from the backup. That way you won't add too much to the primary.
 
Dear Tracker,
you might want to delete snapshots of boot environments which are no more required for you. This would free some space.
 
You can send a zfs stream over a ssh session, i.e
It's actually a local disk - but thanks this is useful to know zfs send/recv. Isn't there an option though where I could just connect the backup disk occasionally to the system and it would automatically mirror the contents? I was under the impression it worked that way.
Replace doas with sudo or whatever floats your boat. This also works with incremental snapshots.
I haven't used doas .... will try to read up on sudo vs doas.
Particularly, if you want to do incremental backups.
What is it about incremental backups specifically?
Also depends on whether the primary system already has compression on. If not and if the files are compressible then the backup disk lasts longer if you turn on compression on the backup.
`zfs get compression` give lz4
you might want to delete snapshots of boot environments which are no more required for you. This would free some space.
That makes sense - although I've had a nasty experience where my zfs got corrupted and had to rely on BEs to save the day - so I'd rather have a few of them
A stupid trick against overflow would be to create a 200 GB file filled with junk and exclude it from the backup. That way you won't add too much to the primary.
Not sure I follow - do you mean I should fill up primary disk with junk? I suppose any kind of mirroring would copy that as well - maybe I am unable to understand what you're suggesting.
 
Not sure I follow - do you mean I should fill up primary disk with junk? I suppose any kind of mirroring would copy that as well - maybe I am unable to understand what you're suggesting.

That would only help if you use a backup method that allows you to exclude the junk file. Rsync, or zfs subfilesystems leaving one out.
 
I was somehow under the impression that zfs raid/mirror setup might work automatically when connecting to the system and mirroring contents automatically. Guess I was wrong.
 
Back
Top