SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


aixrsync
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

aixrsync [2013/02/25 20:30] (current)
sjoerd created
Line 1: Line 1:
 += AIX Rsync =
  
 += Install =
 +Download the latest version from the [[ftp://​ftp.software.ibm.com/​aix/​freeSoftware/​aixtoolbox/​RPMS/​ppc/​|IBM Website]] and install it:
 +
 +<code bash>
 +sjoerd@lpar1:/​tmp/​sft>​sudo rpm -vi rsync-3.0.6-1.aix5.3.ppc.rpm
 +rsync-3.0.6-1
 +sjoerd@lpar1:/​tmp/​sft>​
 +</​code>​
 +
 += Rsync Command =
 +
 +== Setup ==
 +
 +* Local Directory: /​var/​backup/​oracle/​10.2/​archive/​
 +* Destination:​ syncsrv:/​srv/​syncdata/​rsynctest
 +* User performing the sync: syncuser
 +
 +> Note: There must be a [[sshloginwithoutpassword|SSH authorized key setup]]
 +
 +== Options ==
 +
 +^ Option ^ Purpose ^ Remarks |
 +| -r | recursive |Also copy files below the local directory |
 +| -a | archive |will copy owner, group and permissions |
 +| -v | verbose | |
 +| -e | name of remote command to use | allows to use ssh and use a different user for key based authentication |
 +| -delete | delete | deletes files from the destination when required, making it a sync |
 +
 +== Command ==
 +
 +<​code>​
 +rsync -r -a -v -e "ssh -l syncuser"​ --delete /​var/​backup/​oracle/​archive/​ syncsrv:/​srv/​syncdata/​rsynctest
 +</​code>​
 +
 +=== Output Initial Sync ===
 +<​code>​
 +sjoerd@lpar1:/​var/​backup/​oracle/​archive>​rsync -r -a -v -e "ssh -l syncuser"​ --delete /​var/​backup/​oracle/​10.2/​archive/​ syncsrv:/​srv/​syncdata/​rsynctest
 +***************************************************************************
 +NOTICE TO USERS
 +This computer system is the private property of warmetal.nl,​ whether
 +individual, corporate or government. It is for authorized use only.
 +Users (authorized or unauthorized) have no explicit or implicit
 +expectation of privacy.
 +Any or all uses of this system and all files on this system may be
 +intercepted,​ monitored, recorded, copied, audited, inspected, and
 +disclosed to your employer, to authorized site, government, and law
 +enforcement personnel, as well as authorized officials of government
 +agencies, both domestic and foreign.
 +By using this system, the user consents to such interception,​ monitoring,
 +recording, copying, auditing, inspection, and disclosure at the
 +discretion of such personnel or officials. Unauthorized or improper use
 +of this system may result in civil and criminal penalties and
 +administrative or disciplinary action, as appropriate. By continuing to
 +use this system you indicate your awareness of and consent to these terms
 +and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the
 +conditions stated in this warning.
 +****************************************************************************
 +
 +Warning: untrusted X11 forwarding setup failed: xauth key data not generated
 +Warning: No xauth data; using fake authentication data for X11 forwarding.
 +sending incremental file list
 +./
 +popt-1.7-2.aix5.1.ppc.rpm
 +rsync-2.6.2-1.aix5.1.ppc.rpm
 +rsync-3.0.6-1.aix5.3.ppc.rpm
 +
 +sent 541906 bytes  received 72 bytes  83381.23 bytes/sec
 +total size is 541589 ​ speedup is 1.00
 +</​code>​
 +
 +=== Output After File Deletion ===
 +<​code>​
 +sjoerd@lpar1:/​var/​backup/​oracle/​10.2/​archive>​rsync -r -a -v -e "ssh -l syncuser"​ --delete /​var/​backup/​oracle/​10.2/​archive/​ syncsrv:/​srv/​syncdata/​rsynctest
 +***************************************************************************
 +NOTICE TO USERS
 +This computer system is the private property of warmetal.nl,​ whether
 +individual, corporate or government. It is for authorized use only.
 +Users (authorized or unauthorized) have no explicit or implicit
 +expectation of privacy.
 +Any or all uses of this system and all files on this system may be
 +intercepted,​ monitored, recorded, copied, audited, inspected, and
 +disclosed to your employer, to authorized site, government, and law
 +enforcement personnel, as well as authorized officials of government
 +agencies, both domestic and foreign.
 +By using this system, the user consents to such interception,​ monitoring,
 +recording, copying, auditing, inspection, and disclosure at the
 +discretion of such personnel or officials. Unauthorized or improper use
 +of this system may result in civil and criminal penalties and
 +administrative or disciplinary action, as appropriate. By continuing to
 +use this system you indicate your awareness of and consent to these terms
 +and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the
 +conditions stated in this warning.
 +****************************************************************************
 +
 +Warning: untrusted X11 forwarding setup failed: xauth key data not generated
 +Warning: No xauth data; using fake authentication data for X11 forwarding.
 +sending incremental file list
 +./
 +deleting popt-1.7-2.aix5.1.ppc.rpm
 +
 +sent 102 bytes  received 15 bytes  18.00 bytes/sec
 +total size is 462701 ​ speedup is 3954.71
 +</​code>​
 +
 +=== Output After File Add =
 +<​code>​
 +sjoerd@lpar1:/​var/​backup/​oracle/​10.2/​archive>​rsync -r -a -v -e "ssh -l syncuser"​ --delete /​var/​backup/​oracle/​10.2/​archive/​ syncsrv:/​srv/​syncdata/​rsynctest
 +***************************************************************************
 +NOTICE TO USERS
 +This computer system is the private property of warmetal.nl,​ whether
 +individual, corporate or government. It is for authorized use only.
 +Users (authorized or unauthorized) have no explicit or implicit
 +expectation of privacy.
 +Any or all uses of this system and all files on this system may be
 +intercepted,​ monitored, recorded, copied, audited, inspected, and
 +disclosed to your employer, to authorized site, government, and law
 +enforcement personnel, as well as authorized officials of government
 +agencies, both domestic and foreign.
 +By using this system, the user consents to such interception,​ monitoring,
 +recording, copying, auditing, inspection, and disclosure at the
 +discretion of such personnel or officials. Unauthorized or improper use
 +of this system may result in civil and criminal penalties and
 +administrative or disciplinary action, as appropriate. By continuing to
 +use this system you indicate your awareness of and consent to these terms
 +and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the
 +conditions stated in this warning.
 +****************************************************************************
 +
 +Warning: untrusted X11 forwarding setup failed: xauth key data not generated
 +Warning: No xauth data; using fake authentication data for X11 forwarding.
 +sending incremental file list
 +./
 +popt-1.7-2.aix5.1.ppc.rpm
 +
 +sent 79071 bytes  received 34 bytes  12170.00 bytes/sec
 +total size is 541589 ​ speedup is 6.85
 +</​code>​
 +
 += Rsync Script =
 +<code bash>
 +#!/bin/bash
 +########################################################################################################################​
 +# Author : Sjoerd Hooft
 +# Date Initial Version: 11 Jan 2011
 +# Comments: sjoerd_warmetal_nl
 +#
 +# Description:​
 +# This is a script to synchronize Oracle Archive logs.
 +#
 +# Recommendations:​
 +# The script is designed for a 120 column terminal.
 +# The running user must be the oracle user and do a ssh as the replication user based on authorized keys
 +#
 +# Changes:
 +# Please comment on your changes to the script (your name and email address, line number, description):​
 +########################################################################################################################​
 +
 +
 +# Script Variables
 +HOSTNAME_SHORT=`hostname -s`
 +BASEDIR=`dirname $0`
 +LOGFILE="​$BASEDIR/​rsync.log"​
 +WHATAMI=`basename $0`
 +DATE=`date +%Y%m%d%H%M`
 +
 +# Mail Variables
 +. "​$BASEDIR/​mail.txt"​
 +
 +# Oracle Variables
 +ORACLE_HOME="/​opt/​oracle/​product/​10.2"​
 +ORACLE_BASE="/​opt/​oracle"​
 +ORACLE_SID_HOST1=db1
 +ORACLE_SID_HOST2=db2
 +export ORACLE_HOME ORACLE_BASE
 +# Set Oracle SID based on hostname
 +if [ "​$HOSTNAME_SHORT"​ == "​host2"​ ]; then
 +   ​export ORACLE_SID=$ORACLE_SID_HOST2
 +fi
 +if [ "​$HOSTNAME_SHORT"​ == "​host1"​ ]; then
 +   ​export ORACLE_SID=$ORACLE_SID_HOST1
 +fi
 +
 +# Sync Variables
 +ARCHIVEDIR_HOST1="/​var/​backup/​oracle/​10.2/​archive/"​
 +ARCHIVEDIR_HOST2="/​var/​archive/​oracle/​10.2/​arch/"​
 +# Set Archive dir based on hostname
 +if [ "​$HOSTNAME_SHORT"​ == "​host2"​ ]; then
 +   ​export ARCHIVEDIR=$ARCHIVEDIR_HOST2
 +fi
 +if [ "​$HOSTNAME_SHORT"​ == "​host1"​ ]; then
 +   ​export ARCHIVEDIR=$ARCHIVEDIR_HOST1
 +fi
 +TOUSER="​syncuser"​
 +TOHOST="​syncsrv.company.local"​
 +TODIR="/​srv/​syncdata/​Oracle/​${HOSTNAME_SHORT}_${ORACLE_SID}/​archive"​
 +
 +mailFunction() {
 +   if [ "​$1"​ == "​SUCCESS"​ ]; then
 +      cat $LOGFILE | mail -s "​Success Sync $WHATAMI ${HOSTNAME_SHORT}!"​ $MAILTOSUCCESS
 +   fi
 +   if [ "​$1"​ == "​FAILED"​ ]; then
 +      cat $LOGFILE | mail -s "​FAILED Sync $WHATAMI ${HOSTNAME_SHORT}!"​ $MAILTOFAIL
 +   fi
 +}
 +
 +rsyncFunction() {
 +   # Start with clean logfile
 +   echo > $LOGFILE
 +   echo "​Starting Synchronization of $ARCHIVEDIR on $HOSTNAME_SHORT to ${TOHOST}:​${TODIR}"​ >> $LOGFILE
 +   echo >> $LOGFILE
 +   /​usr/​bin/​rsync -r -a -v -e "ssh -l $TOUSER"​ --delete --log-file=$LOGFILE $ARCHIVEDIR ${TOHOST}:​${TODIR}
 +   if [ "​$?"​ == "​0"​ ]; then
 +      mailFunction SUCCESS
 +   else
 +      mailFunction FAILED
 +   fi
 +}
 +
 +rsyncFunction
 +exit
 +</​code>​
 +
 += Exclude Directories =
 +Define excludedirectories and add them to the command:
 +<​code>​
 +/​usr/​bin/​rsync -a -v -e "ssh -l $TOUSER"​ --exclude "​$EXCLUDEDIR1"​ --exclude "​$EXCLUDEDIR2"​ --log-file=$LOGFILE $LDAPDIR ${TOHOST}:​${TODIR}
 +</​code>​
 +
 +{{tag>​aix storage scripts tools}}
aixrsync.txt ยท Last modified: 2013/02/25 20:30 by sjoerd