Brian

This is a chunk of a script I wrote: To make it go to another machine change the send/receive something like the other example below

Creates a copy of a zfs filesystem and mounts it on the local machine (the "do_command" just made my demo self running).

scrubbing is easy just a cron entry!

Code Chunk 1

if [ -d $COPY_DIR ]; then
    echo "============================="
    echo "Make a copy of my current $HOME_DIR in $COPY_DIR"
    echo "============================="
    # Work out where $HOME_DIR and $COPY_DIR are located in ZFS
    #
    HOME_POOL=`/bin/df -h $HOME_DIR | grep  $HOME_DIR | awk '{ print $1 }' | head -1`
    # This only works if /Backup is mounted and I now umount it so I can always mount /Backup/home.
    # I had problems when I used the top dir as a filesystem when reboot after an LU.
    #COPY_POOL=`/bin/df -h $COPY_DIR | grep  $COPY_DIR | awk '{ print $1 }' | head -1`
    COPY_POOL=`/usr/sbin/zfs list | grep $COPY_DIR | grep -v $HOME_DIR | awk '{ print $1 }' | head -1`
    # Use zfs send and recieve
    #   
    # /usr/sbin/zfs destroy -fR $COPY_POOL$HOME_DIR # It can exist!
    /usr/sbin/zfs destroy -fR $home_p...@now 1>/dev/null 2>&1 #Just in case we aborted for some reason last time
     /usr/sbin/umount -f $COPY_DIR/$HOME_DIR  1>/dev/null 2>&1 # Just is case somebody is cd'ed to it
   sync
    usr/sbin/zfs snapshot $home_p...@now && \
    /usr/sbin/zfs send $home_p...@now |  /usr/sbin/zfs receive -F $COPY_POOL$HOME_DIR && \
    /usr/sbin/zfs destroy $home_p...@now
    /usr/sbin/zfs destroy $copy_pool$home_...@now
    /usr/sbin/zfs umount $COPY_POOL 1>/dev/null 2>&1 # It should not be mounted
    /usr/sbin/zfs set mountpoint=none $COPY_POOL
    /usr/sbin/zfs set mountpoint=$COPY_DIR$HOME_DIR  $COPY_POOL$HOME_DIR
   /usr/sbin/zfs mount $COPY_POOL$HOME_DIR
    /usr/sbin/zfs set readonly=on $COPY_POOL$HOME_DIR
    sync
    /bin/du -sk $COPY_DIR/$HOME  >> /tmp/email$$
fi


Code chunk 2

How I demoed send/recieve

# http://blogs.sun.com/timc/entry/ssh_cheat_sheet
#
# [r...@norton:] ssh-keygen -t rsa
#          no pass phrase
# [r...@norton:] cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
#
# Edit /etc/ssh/sshd_config, change line to
#     PermitRootLogin yes
#
# [r...@norton:] svcadm restart ssh

############################################
## Lets send the snaphost to another pool ##
############################################
echo ""
echo ""
echo "Create a new pool and send the snaphot to it to back it up"
echo ""
echo "Note: The pool could be on a remote systems"
echo "I will simply use ssh to localhost"
echo ""
do_command zpool create backup_pool $DISK5
do_command zpool status backup_pool
press_return
# Note do_command does not work via the pipe so I will just use echo
# Need to setup ssh - see notes above
echo ""
echo ""
echo "------> zfs send sap_pool/PRD/sapda...@today | ssh localhost zfs receive -F backup_pool/sapdata1"
echo ""
zfs send sap_pool/PRD/sapda...@today | ssh localhost zfs receive -F backup_pool/sapdata1
do_command df -h /sapdata1
do_command df -h /backup_pool/sapdata1
echo ""
echo "Notice the backup is not compressed!"
echo ""
press_return
do_command ls -alR /backup_pool/sapdata1 | more

Brian wrote:
Thank you, Ill definitely implement a script to scrub the system, and have the system email me if there is a problem.
  

--





cid:image001.png@01C8E355.AFFC1E00Trevor Pretty | Technical Account Manager | +64 9 639 0652 | +64 21 666 161
Eagle Technology Group Ltd.
Gate D, Alexandra Park, Greenlane West, Epsom
Private Bag 93211, Parnell,
Auckland




www.eagle.co.nz 

This email is confidential and may be legally privileged. If received in error please destroy and immediately notify us.

_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to