projects
/
zfs-ubuntu
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added support to replicate and restore from multiple backup pools
[zfs-ubuntu/.git]
/
zfs-restore-all
diff --git
a/zfs-restore-all
b/zfs-restore-all
index 7d174b46fbefd86045e01d426a36e7da81601526..dbe09a1d57c9a761afb166d6659ec901ac90cb68 100755
(executable)
--- a/
zfs-restore-all
+++ b/
zfs-restore-all
@@
-22,7
+22,6
@@
cleanup_and_exit() {
}
trap cleanup_and_exit INT
}
trap cleanup_and_exit INT
-
# See if the user has a specific pool to restore in mind
restore_pool=$1
# See if the user has a specific pool to restore in mind
restore_pool=$1
@@
-31,16
+30,26
@@
echo `date` ZFS restore started
# For each filesystem we are supposed to restore, do it
for filesystem in $filesystems_to_replicate; do
# For each filesystem we are supposed to restore, do it
for filesystem in $filesystems_to_replicate; do
+ if [[ $filesystem =~ ':' ]]; then
+ src_pool=${filesystem%%:*}
+ filesystem=${filesystem#*:} # remove src_pool from string
+ else
+ src_pool=${backup_pool%% *} # use the first backup pool if none specified
+ fi
dst_pool=${filesystem%%/*}
dst_fs=${filesystem#*/}
# Check to make sure the dst filesystem does not exist
dst_pool=${filesystem%%/*}
dst_fs=${filesystem#*/}
# Check to make sure the dst filesystem does not exist
- ssh $remote "$zfs list ${dst_pool}/${dst_fs}" > /dev/null 2>&1
+ if [[ $remote = "localhost" ]]; then
+ $ssh $remote $zfs list ${dst_pool}/${dst_fs} > /dev/null 2>&1
+ else
+ $zfs list ${dst_pool}/${dst_fs} > /dev/null 2>&1
+ fi
if [ $? != 0 ]; then
echo "$filesystem" | grep -q "$restore_pool"
if [ $? == 0 ]; then
# This filesystem matches our restore pool pattern
echo `date` Restoring $filesystem to $remote
if [ $? != 0 ]; then
echo "$filesystem" | grep -q "$restore_pool"
if [ $? == 0 ]; then
# This filesystem matches our restore pool pattern
echo `date` Restoring $filesystem to $remote
- zfs-restore $
local
_pool $filesystem $dst_pool $dst_fs $remote
+ zfs-restore $
src
_pool $filesystem $dst_pool $dst_fs $remote
fi
else
echo "-I- Filesystem already exists on destination. Skipping: $filesystem"
fi
else
echo "-I- Filesystem already exists on destination. Skipping: $filesystem"