Skip to content

Instantly share code, notes, and snippets.

@zenodotus280
zenodotus280 / tank-backup.sh
Created August 21, 2023 04:22
ZFS Backup: Local Pool to External Drive
#!/bin/bash
# Use Case: Plug in USB hard drive, run the script, wait for notification, unplug drive.
# This script assumes you've already set up sanoid, syncoid, cron (with flock), and the pools. It's essentially a wrapper for the following commands:
# ------------------------------------------------------------------
# zpool import tank-backup
# sanoid --cron --verbose # pruning on both pools
# syncoid --skip-parent --recursive --compress lzo tank tank-backup
# zpool export tank-backup
# ------------------------------------------------------------------
# This could be modified to work on specific datasets but I don't have a need for that right now.