Difference between revisions of "Time Machine Backups"
(→zvols) |
|||
Line 70: | Line 70: | ||
<code>sudo diskutil coreStorage convert disk5s2 -passphrase</code> | <code>sudo diskutil coreStorage convert disk5s2 -passphrase</code> | ||
− | Please note, this process can take a considerable amount of time (several hours for a 1TB volume). | + | Please note, this process can take a considerable amount of time (several hours for a 1TB volume). You can check on the progress of the encryption using the following command: |
+ | |||
+ | <code>diskutil cs list | grep -e "Conversion" -e "Volume Name"</code> |
Revision as of 05:35, 19 October 2018
Time Machine Backups
There are two approaches to using ZFS for Time Machine Backups - Sparsebundles on a ZFS data set and zvols formatted as HFS+.
Sparsebundles
Here's one approach to using ZFS for your Time Machine Backups.
Because Time Machine doesn't recognize ZFS datasets as a compatible disk for Time Machine backups, as a work around, we create an HFS+ sparsebundle disk image, store it on a ZFS dataset, and set the mounted image as a backup destination (no "TMShowUnsupportedNetworkVolumes" needed).
1. Create, and mount, a sparsebundle from a ZFS dataset (e.g., with makeImage.sh or Disk Utility.app).
2. Set the sparsebundle as the (active) backup destination:
# tmutil setdestination -a /Volumes/[sparse bundle volume name]
While it has been discussed in heated arguments (e.g., https://github.com/openzfsonosx/zfs/issues/66) I still believe there's at least one ZFS feature I'd like to test with Time Machine: compression.
The hypothesis being that an HFS+ sparsebundle stored on a compressed (gzip, lz4), deduped dataset should yield a compression ratio > 1.0 (previously observed 1.4 with compression=on, dedup=off, FreeBSD network Time Machine drives).
zvols
1. Create a zvol to use for Time Machine backups:
sudo zfs create -V [size] [pool]/[volume]
For example, the following will create a 1TB volume named tmdisk1 on a zpool named Backup:
sudo zfs create -V 1T Backup/tmdisk1
2. Get OSX disk number corresponding to the zvol:
ioreg -trn "ZVOL [pool]/[volume] Media" | awk -F'"' '/BSD Name/ {print $4;}'
For example, if a zvol named tmdisk1 was created as shown above, the following will get its disk number and store it in the shell variable DISKID:
ioreg -trn 'ZVOL Backup/tmdisk1 Media' | awk -F'"' '/BSD Name/ {print $4;}'
3. Format the zvol as a HFS+, using its disk number from step 2:
sudo diskutil eraseDisk JHFS+ [OSX Disk Name] [disk number]
For example, if the zvol was disk5 in OSX, the following will format that disk as a HFS+ disk named "TimeMachine":
sudo diskutil eraseDisk JHFS+ "TimeMachine" disk5
4. Set the zvol as a Time Machine destination:
sudo tmutil setdestination -a /Volumes/[OSX Disk Name]
For example, if the zvol was formatted as HFS+ named "TimeMachine" in step 3, the following will set it as a Time Machine destination:
sudo tmutil setdestination -a /Volumes/TimeMachine
5. (Optional) Enable encryption for Time Machine backups on the zvol:
5.1 Get the disk identifier for the HFS+ disk on the zvol:
diskutil list [OSX Disk Name] | awk '/[OSX Disk Name]/ { print $NF;}'
For example, if the zvol was formatted as HFS+ named "TimeMachine" in step 3, the following will get its disk identifier:
diskutil list TimeMachine | awk '/TimeMachine/ { print $NF; }'
5.2 Convert the HFS+ disk to use encryption:
sudo diskutil coreStorage convert [Disk ID] -passphrase
This will ask for the encryption password (which may be stored in the Keychain). For example, if the if the zvol was formatted as HFS+ named "TimeMachine" in step 3, whose disk identifier was returned as disk5s2 in step 5.1, the following will convert the disk to use encryption:
sudo diskutil coreStorage convert disk5s2 -passphrase
Please note, this process can take a considerable amount of time (several hours for a 1TB volume). You can check on the progress of the encryption using the following command:
diskutil cs list | grep -e "Conversion" -e "Volume Name"