Solved how to restore snapshot from other location(example. other pool, other usb disk, etc) in zfs ? thanks

Dear all :
I have used FreeBSD 14 with ZFS system. Below is my pool info .
Code:
root@xxx:~ # zpool list
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
p200   19.5G  1.10M  19.5G        -         -     0%     0%  1.00x    ONLINE  -
zroot  17.5G   559M  17.0G        -         -     0%     3%  1.00x    ONLINE  -
Now I make a backup of zroot/home dataset with snapshot
Code:
root@xxx:~ # zfs list -t snapshot
NAME             USED  AVAIL  REFER  MOUNTPOINT
zroot/home@222     0B      -    96K  -
I have used zfs send and receive command to save this snapshot to p200 .
zfs send zroot/home@222 | zfs receive p200/backup
########## I am not sure these command is right ......can you show me right command to save snapshot to other location (example. other pool, other usb disk, etc)

question : how to zfs rollback the other location snapshot (example , my p200 pool snapshot )to my current system ?

thanks. .........
 
Your command for local backup is OK, but be aware that your p200/backup is not mounted automatically on startup. The restore command is opposite to backup:
zfs send p200/backup@222 | zfs receive zroot/new-home

For remote backups you can use ssh, this requires appropriate permissions on remote host (or root):
zfs send zroot/home@222 | ssh <remote-host> zfs receive p200/backup

To automate these tasks you can use some useful tools from ports, for example sysutils/py-zfs-autobackup or sysutils/zrepl
 
Your command for local backup is OK, but be aware that your p200/backup is not mounted automatically on startup. The restore command is opposite to backup:
zfs send p200/backup@222 | zfs receive zroot/new-home

For remote backups you can use ssh, this requires appropriate permissions on remote host (or root):
zfs send zroot/home@222 | ssh <remote-host> zfs receive p200/backup

To automate these tasks you can use some useful tools from ports, for example sysutils/py-zfs-autobackup or sysutils/zrepl
Dear shurik :
i got it .thanks.
 
Note that "zfs send" output can be saved as a plain file. So to backup a snapshot onto a stick, mount the stick, then
zfs send p200/backup@222 > /media/stick/p200-backup@222.
To restore, "zfs receive" reads from stdin:
zfs receive p200/backup < /media/stick/p200-backup@222.
Dear schweikh:
thanks. it's very good sulotion.
 
You can also take note of but avoid using options of a dataset on the backup destination. An example (with a few other flags I usually use)
zfs send -LeRv home@222|zfs recv -x mountpoint -x bootfs -x compression -x atime -x refreservation -x readonly p200/backup
Then you can restore the overrides with on restore.
zfs send -bLeRv p200/backup@222|zfs recv home
Using temporary overrides allows for options like having a read only backup, using different compression on the backup, avoiding automounting the backup, etc. Saving the send stream to a file would avoid any need to use flags to override+restore the options but loses advantages like browsing the backup and copying parts of it without a complete restore. I consider it a bug to have documentation with examples not teach people which -x flags to use on their backup to avoid the backup automounting over the live filesystem. The proper solution is to review altered options and decide which ones to not set on the backup with zfs get -rHp all home | egrep 'local$' and probably rerunning that on the backup itself too.
You can also do other useful things like incremental snapshots.
 
Back
Top