Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@akorn
Created October 15, 2018 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akorn/974c6a1189470ebe87668b15594262e1 to your computer and use it in GitHub Desktop.
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
#!/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