Source for the Z3 tool is at https://github.com/presslabs/z3 . This source will backup the zfs snapshots to a S3 bucket. I have made some modifications with the help of boto3 and botocore python modules and made the Z3 tool to restore the snapshots too from the S3 bucket.
Compiled and modified Z3 tool files are at https://gitlab.com/freebsd1/z3 . Since it’s a public repository, anyone can download it and follow the instructions in README file.
Once all the files are moved over to the appropriate location, we can configure the z3 tool using z3.conf file located at /etc directory.
- BUCKET => This field requires the name of the S3 bucket.
- S3_KEY_ID => It is the ACCESS KEY ID provided by the Amazon. For reference click here.
- S3_SECRET => Secret Access Key provided by the Amazon to access S3. For reference click here.
- S3_REGION => Region name where you have created S3 bucket.
- host => Hostname of your S3 bucket, make sure it includes region name.
Above fields are mandatory and rest parameters determines the working nature of z3 tool.
- S3_PREFIX => This prefix name is used where all your zfs snapshots are stored under it. So there will be a directory created in the bucket and backups are stored under it.
- FILESYSTEM => z3 take snapshot of filesystem by default when specified.
- SNAPSHOT_PREFIX => To backup only certain snapshots.
- COMPRESSOR => To default compression level.
Viewing status for the transferred snapshots in s3 bucket
#z3 –filesystem tank/data status
Transferring zfs file system snapshot to a S3 bucket
#z3 –filesystem tank/dummy backup –snapshot snap_oct14
Here snapshot name is specified and also the filesystem parameter is specified to backup the snapshot of particular zfs dataset.
Restoring zfs file system from the snapshot located in S3 bucket.
#z3 –filesystem tank/dummy restore snap_oct14 –force
Here ‘force’ option is used since the snapshot ‘snap_oct14’ type is incremental. Before restoring, the file system ‘tank/dummy’ is completely destroyed using the command ‘zfs destroy –r tank/dummy’.
Now we can use this z3 tool to store & retrieve zfs snapshots from a remote S3 bucket.