Table des matières

Copy/move a pool with all snapshots

  1. find the oldest snapshot of the source pool and send it to the target pool
  2. find the most recent snapshot of the source pool and send the incremental

Destroy many snapshots

https://gist.github.com/paulhandy/45571e2077df83829fcc6dac1cfedd1a
Pour enlever tous les snapshots d'un dataset?

https://serverfault.com/questions/340837/how-to-delete-all-but-last-n-zfs-snapshots#340846

You may find something like this a little simpler

zfs list -t snapshot -o name | grep '^tank@Auto' | tac | tail -n +16 | xargs -n 1 zfs destroy -r

    output the list of snapshot (names only) with zfs list -t snaphot -o name
    filter to keep only the ones that match tank@Auto with grep ^tank@Auto
    reverse the list (previously sorted from oldest to newest) with tac
    limit output to the 16th oldest result and following with tail -n +16
    then destroy with xargs -n 1 zfs destroy -vr

deleting snapshots in reverse order is supposedly more efficient.

or sort in reverse order of creation

zfs list -t snapshot -o name -S creation | grep '^tank@Auto' | tail -n +16 | xargs -n 1 zfs destroy -vr

Test it with ...|xargs -n 1 echo 
the argument of the “grep” is a regex!
….use .* to replace any characters one or more times…..8-)

Find snapshots

the oldest

# zfs list -H -o name -t snapshot -r the_pool_name -S creation | tail --lines=1
 -- or --
# zfs list -H -o name -t snapshot -r the_pool_name -S creation | grep "name_of_the_snapshots" | tail --lines=1 

the most recent

# zfs list -H -o name -t snapshot -r the_pool_name | tail --lines=1
 -- or --
# zfs list -H -o name -t snapshot -r the_pool_name | grep "name_of_the_snapshots" | tail --lines=1 

Look into a snapshot

Look into tank/my_dataset@my_snapshot:

# ls /mnt/tank/my_dataset/.zfs/snapshot/my_snapshot       ### under /mnt for FreeNAS, /rpool for Proxmox

It is possible to go down into subfolders and to copy from this place to another place in the “normal” file system.

Scrub a pool

Run a scrub job on pool “tank”:

# zpool scrub tank           ### top start the job
#zpool status -v tank          ### to monitor the job 

trucs divers

https://unix.stackexchange.com/questions/263677/how-to-one-way-mirror-an-entire-zfs-pool-to-another-zfs-pool

DokuWiki Appliance - Powered by TurnKey Linux