Solved Issue with ZFS remote replication of snapshots...

I am trying to write a script in Python 3.7 that will run at night and keep an exact replica of a source ZFS pool on a remote machine, all datasets and snapshots included. Of course, it has to an incremental replication. I know for one thing that I can use the subprocess module, but that has proved to be very difficult so far. I would like to know if there is a Python library that I can use.
 
First i would use python3.9 as this is the default.
And then i make snapshots but not using python but sh as shell script, this is also an option.
This is the code of the incremental snapshots i make every 15 minutes,
Code:
export       source="ZT/usr/home"
export         dest="ZHD/usr_home_hourly"
export       mydate=`/bin/date "+%Y_%m_%d__%H_%M_%S"`
export      current=${source}@${mydate}
export previous=` /sbin/zfs list -t snap -r ${source} | /usr/bin/grep ${source}@  | /usr/bin/awk 'END{print}' | /usr/bin/awk '{print $1}'`
/sbin/zfs snapshot             ${current}
echo "OLD:" ${previous} ${current}
echo "NEW:" ${dest}
/sbin/zfs send -i ${previous} ${current} | /sbin/zfs receive ${dest}
 
First i would use python3.9 as this is the default.
And then i make snapshots but not using python but zsh as shell script, this is also an option.

My problem is that I have not been able to send more than one snapshot of a given dataset. I guess I need deeper knowledge of the ZFS replication feature. Any recommended reading?
 
It's not that complicated once you understand the finesse.

There are the books of Michael Lucas,

 
Back
Top