Created
October 15, 2018 10:46
-
-
Save akorn/974c6a1189470ebe87668b15594262e1 to your computer and use it in GitHub Desktop.
Script to back up zfs metadata, also in the form of zfs create commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
zfs get all -Hp -s local,received >/var/backups/zfs-properties.txt | |
zpool get all >/var/backups/zpool-properties.txt | |
for i in $(zfs list -t filesystem,volume -H -o name); do | |
unset props | |
zfs get all -o property,value -Hp -s local,received $i | while read prop value; do | |
props=($props[@] "-o $prop"="'$value'") | |
done | |
echo zfs create ${(o)props[@]} $i | |
done >/var/backups/zfs-create-commands.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment