Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exclusions of datasets during zfs send/recv. #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions zxfer
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ grep ^$source@) > /dev/null 2>&1
#
get_zfs_list() {

if [ "$option_E" != "" ]; then # add user-specified exclude patterns.
zfs_list_exclude=$(echo "-v -e $option_E" | sed -e "s/\,/ -e /g" | sed -e "s/--exclude=//g")
fi

# 0 if not a trailing slash; regex is one character of any sort followed by
# zero or more of any character until "/" followed by the end of the
# string.
Expand All @@ -680,8 +684,12 @@ get_zfs_list() {

rzfs_list_ho_s=$($RZFS list -t filesystem,volume -Ho name -s creation) ||
{ echo "Failed to retrieve datasets from the destination"; exit 3; }
lzfs_list_hr_s_snap=$($LZFS list -Hr -o name -s creation -t snapshot $initial_source) ||
if [ "$option_E" != "" ]; then
lzfs_list_hr_s_snap=$($LZFS list -Hr -o name -s creation -t snapshot $initial_source | grep $zfs_list_exclude) ||
{ echo "Failed to retrieve snapshots from the source"; exit 3; }
else lzfs_list_hr_s_snap=$($LZFS list -Hr -o name -s creation -t snapshot $initial_source) ||
{ echo "Failed to retrieve snapshots from the source"; exit 3; }
fi
# Note that for OpenSolaris compatibility, instead of using gtac
# we will use ...| cat -n | sort -nr | cut -c 8-
# gtac line
Expand All @@ -690,8 +698,12 @@ get_zfs_list() {
rzfs_list_hr_S_snap=$($RZFS list -Hr -o name -S creation -t snapshot $destination) ||
{ echo "Failed to retrieve snapshots from the destination"; exit 3; }

recursive_source_list=$($LZFS list -t filesystem,volume -Hr -o name "$initial_source") ||
if [ "$option_E" != "" ]; then
recursive_source_list=$($LZFS list -t filesystem,volume -Hr -o name "$initial_source" | grep $zfs_list_exclude) ||
{ echo "Failed to retrieve list of datasets from the source"; exit 3; }
else recursive_source_list=$($LZFS list -t filesystem,volume -Hr -o name "$initial_source") ||
{ echo "Failed to retrieve list of datasets from the source"; exit 3; }
fi
recursive_dest_list=$($RZFS list -t filesystem,volume -Hr -o name "$destination") ||
{ echo "Failed to retrieve list of datasets from the destination"; exit 3; }

Expand Down
8 changes: 8 additions & 0 deletions zxfer.8
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ often gets deleted on the source. Any snapshots on the destination more
recent than the most recent common snapshot must be deleted for
.Cm zfs send
to work.
.It Fl E
(E)xclude specified datasets from source list. e.g. if you want to exclude
some datasets from receiving list, then use "-E mypool/exclude1,mypool/exclude2".
You must to use this option one time and specify all exclusions comma separated.
You can use only name dataset without full path with pool name etc,
but in this case you will exclude all datasets, that includes this name.
e.g. "-E exclude" will excluding and mypool/exclude, and mypool/path/to/exclude2.
When you specified some dataset for exclusion, you also exclude all them childs.
.It Fl g
(g)randfather protection. Specify a number of days old (relative to the system
date) at and above which snapshots on the destination won't be deleted. For use
Expand Down