Skip to main content

Bash Script For Transferring Or Synchronizing RMAN Backup Files From One Server (SourceSrv) To Another Server (DestinationSrv) And Deleting Old RMAN Backup Files




Bash Script For Transferring Or Synchronizing RMAN Backup Files From One Server (SourceSrv) To Another Server (DestinationSrv) And Deleting Old RMAN Backup Files



Source Host: SourceSrv                                                         Destination Host: DestinationSrv

LogIn on DestinationSrv:

mkdir -p /home/rony/.scripts/

touch /home/rony/.scripts/rsync.sh

touch /home/rony/.scripts/rsync.log

chmod u+x /home/rony/.scripts/rsync.sh

For killall command install: sudo dnf search psmisc


tee /home/rony/.scripts/rsync.sh >/dev/null <<EOF

#!/bin/bash

##################################################################################################################

export Script=/home/rony/.scripts/

export Source=rony@SourceSrv:/u01/rman_backup/

export Destination=/u01/db_backup/backup_from_DestinationSrv/rman/backup_files/

export LogFile=${Script}/rsync.log

echo 'Source : '${Source} 2>&1 | tee -a ${Script}/rsync.log

echo 'Destination : '${Destination} 2>&1 | tee -a ${Script}/rsync.log

##################################################################################################################

echo 'Task-01: Kill already running rsync process. Start at '$(date) 2>&1 | tee -a ${Script}/rsync.log

sleep 30

killall rsync

sleep 30

echo 'Task-01: Kill already running rsync process. End at '$(date) 2>&1 | tee -a ${Script}/rsync.log

##################################################################################################################

echo 'Task-02: Transfering RMAN Backup Files From '${Source}' to '${Destination}'.. Start at '$(date) 2>&1 | tee -a ${Script}/rsync.log

sleep 30

rsync --log-file=${LogFile} -avrPh --force -e ssh ${Source} ${Destination}

sleep 30

echo 'Task-02: Transfering RMAN Backup Files From '${Source}' to '${Destination}'.. End at '$(date) 2>&1 | tee -a ${Script}/rsync.log

##################################################################################################################

echo 'Task-03: Deleting 10 Days Older Files.. Start at '$(date) 2>&1 | tee -a ${Script}/rsync.log

echo 'Print all dir------------------------------------------------Start' 2>&1 | tee -a ${Script}/rsync.log

for dir in ${Destination[@]}

do

 echo 'Backup_Diretory: '$dir 2>&1 | tee -a ${Script}/rsync.log

 for readDir in $dir

 do

 echo 'Reading_Directory: ' $readDir 2>&1 | tee -a $Script/rsync.log cd $readDir #ls echo 'pwd: ' $(pwd) 2>&1 | tee -a $Script/rsync.log

 echo 'Print ten days older all files------------------------------------------------Start' 2>&1 | tee -a ${Script}/rsync.log

 for file in $(find $readDir -mtime +7)

 do

 echo 'File_name : '$file 2>&1 | tee -a ${Script}/rsync.log

 echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

      echo 'delete start for the file: '$file 2>&1 | tee -a ${Script}/rsync.log

      echo 'Please wait................' 2>&1 | tee -a ${Script}/rsync.log

      rm -rfv $file

      echo 'delete completed for the file: '$file 2>&1 | tee -a ${Script}/rsync.log

 echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

 done

 echo 'Print ten days older all files------------------------------------------------End' 2>&1 | tee -a ${Script}/rsync.log

 done

done

echo 'Print all dir------------------------------------------------End' 2>&1 | tee -a ${Script}/rsync.log

echo 'Task-03: Deleting 10 Days Older Files.. End at '$(date) 2>&1 | tee -a ${Script}/rsync.log

##################################################################################################################

EOF


crontab -e

#11 18 * * * /home/rony/.scripts/rsync.sh


watch -n 1 'tail -n 29 /var/log/cron'

watch -n 1 'ps -axuwwf | grep rsync'

watch -n 1 'tail -n 29 /home/rony/.scripts/rsync.log'




Comments

Popular posts from this blog

Upgrading Issue for RHEL 7 to 8 With Leapp

Overview The Leapp utility is a framework for updating and upgrading operating systems as well as applications. The operations of this utility consist of two phases 1. the preupgrade Phase – that chack the upgrade possibilities and 2. the actual upgrade phase – that map packages between previous and current versions of the software packages. Issue – 01: After running ‘ sudo leapp preupgrade ‘ sometimes you find the below issue in ‘ /var/log/leapp/leapp-report.txt ‘. Detail: Risk Factor: high (inhibitor) Title: Leapp detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed. Summary: Support for the following RHEL 7 device drivers has been removed in RHEL 8: – pata_acpi Key: f08a07da902958defa4f5c2699fae9ec2eb67c5b Remediation: 1. Disable detected kernel drivers in order to proceed with the upgrade process using the rmmod or modprobe -r . rmmod – Simple program to remove a module from the Linux Kernel modprobe – Add and remove modules from the Linux Ke

Upgrading Oracle Linux 6 to 7

Overview It is possible to upgrade an Oracle Linux 6 system to Oracle Linux 7.6 under the following conditions: The system meets the minimum installation requirements for Oracle Linux 7 as described in Chapter 1, System Requirements and Limits. The Oracle Linux 6 system has been completely updated from the ol6_x86_64_latest channel or ol6_latest repository. UEK R3 or UEK R4 has been installed on the system to be upgraded and is the default boot kernel. Upgrading from UEK R2 is not supported. Note that the system is upgraded to use the UEK R5 release provided with Oracle Linux 7.6. Upgrading is supported only for systems that are installed with the Minimal Install base environment. If additional packages are installed from an alternative repository or channel, upgrade might fail or the resulting upgrade might not function as expected. reference: https://docs.oracle.com/en/operating-systems/oracle-linux/7/relnotes7.6/ol7-install.html#ol7-upgrade-ol6 Verifying the system before Upgrade: #

Software-only Installation of oracle Database 21c on RHEL 8

Overview Oracle Database 21c is a multi-model database that provides full support for relational and non-relational data, such as JSON, XML, text, spatial and graph data. There are lots of new features available in this new release like partitioned hybrid tables, encryption capabilities in the built-in data dictionary, statistics-only queries, and many more. It also enables Oracle's Autonomous Database Cloud Services. This article describes the installation of Oracle Database 21c 64-bit on Red Hat 8 64-bit. Lab Environment Particulars                                     Database Info --------------                                            ------------------------------------------------------- OS Release                                     Red Hat Enterprise Linux release 8.4 (Ootpa) Kernel                                              4.18.0-425.10.1.el8_7.x86_64 IP Address                                     1 92.168.0.10 Host Name                                  oemsrv User Na