Sponsored Content
Top Forums Shell Programming and Scripting Script to automate recovery process Post 302944513 by RogerBaran on Tuesday 19th of May 2015 09:25:25 PM
Old 05-19-2015
Thank you very much for your reply.
I have been reading so much information in the last couple of days that when I got to doing a for loop, by brain just shut off! I feel embarrassed that it was such an "easy" piece of script!

The last piece of this will be to run rsync against the backups to the newly mounted VG/LVM's.

Thank you very much!!

Roger

---------- Post updated at 05:42 PM ---------- Previous update was at 05:19 PM ----------

Quote:
Originally Posted by Chubler_XL
Code:
read -a farray <<<< $(grep $vgname ....)

for fs in ${farray[@]}
do
    mkdir /mnt/$vgname/$fs
    mount /dev/mapper/${vgname}-${fs}
done

Sorry to bother you again, but I forgot that I need a list of exclusions when it comes to restoring the root...

Is there a way to exclude root in the first section and then do just root in the second part?
Also, can we "variable-ize" the rsync line in the second part???

Thank you very much in advance!!
Roger

Code:
echo "Creating Mount Points, mounting individual LVM's from Volume Group and restoring data..."
for fs in ${farray[@]}
do
    mkdir /mnt/$vgname/$fs
    mount /dev/mapper/${vgname}-${fs} /mnt/$vgname/$fs
    rsync -aHvu /mnt/USBDrive/Recover/$fs /mnt/$vgname/$fs
done

# Restoring root requires all of the other lvm's as excludes...
# rsync -aHvu --exclude={/backup/*,/home/*,/opt/*,/tmp/*,/usr/*,/usr/local/*,/var/*}

---------- Post updated at 08:13 PM ---------- Previous update was at 05:42 PM ----------

Ok. I may have come up with a workaround...

By not sorting the list prior to reading it into the array, root will always be ${farry[0]}. Therefore, I can start my mkdirs and mounts with ${farry[1]} and then come back and do ${farry[0]} at the end.

How do we create and increment a variable to read in everything from 1 through an empty offset and perform our actions using their values in the commands?

---------- Post updated at 08:25 PM ---------- Previous update was at 08:13 PM ----------

Answer:
Code:
for fs in ${farray[@]:1}
do
    mkdir /mnt/$vgname/$fs
    mount /dev/mapper/${vgname}-${fs} /mnt/$vgname/$fs
    rsync -aHvu /mnt/USBDrive/Recover/$fs /mnt/$vgname/$fs
done

After that we can come back with
Code:
    mkdir /mnt/$vgname/${farray[0]}
    mount /dev/mapper/${vgname}-${farray[0]} /mnt/$vgname/${farray[0]}
    rsync -aHvu --exclude={/backup/*,/home/*,/opt/*,/tmp/*,/usr/*,/usr/local/*,/var/*} /mnt/USBDrive/Recover/${farry[0]} /mnt/$vgname/${farry[0]}

Last step:
To "auto-variable-ize" the rsync exclusions for / restoration...

Last edited by RogerBaran; 05-21-2015 at 11:18 AM.. Reason: minor corrections to text
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to automate an FTP process?

Hello script experts, I am newbie to shell script. But I have to write a shell script (ASAP) where I need to ftp a file on daily basis to a remote server, and send an email with final status. I I should have a properties file with hostname, Userid, and pwd. And a shall script file should read... (1 Reply)
Discussion started by: ksak
1 Replies

2. Shell Programming and Scripting

Automate Log Monitoring Process

I am a new member of this forum and am also new to unix shell scripting. I joined the forum to seek for help to achieve my task as this forum helps people. here's what i do manually on daily basis 1)Loginto different unix box 2)Ftp the log files (morethan 50 each dir) to windows 3)use text pad... (3 Replies)
Discussion started by: sharugan
3 Replies

3. Shell Programming and Scripting

Error in script to automate the daily monitoring process of UNIX server and it's proc

hi friends, I am trying to automate the daily monitoring process of UNIX server and it's processes. the script are below i executed the above script using ksh -x monitortest1.sh in root login . It shows error at some lines . 1. i logged in using root ,but it... (8 Replies)
Discussion started by: rdhaprakasam
8 Replies

4. Shell Programming and Scripting

To automate a process

CAN ANYONE HELP TO SOLVE i wann write a script to automate a process .i.e, to search files in the FTP server and and if files are there and we hav to bring that files to our system. After copying the files in our system we have to upload the data in the tables. I have scripts to load the... (0 Replies)
Discussion started by: nani1984
0 Replies

5. UNIX for Advanced & Expert Users

TO Automate the FTP process

Plzz Some One Help in this matter I have scripts to load the data into tables and to copy files from ftp to our system. we use to run the scripts every day.... we hav the files in the FTP server and we hav to bring the files to our system and we hav to load the data into the tables. We... (0 Replies)
Discussion started by: nani1984
0 Replies

6. UNIX for Dummies Questions & Answers

To automate a process

CAN ANYONE HELP TO SOLVE i wann write a script to automate a process .i.e, to search files in the FTP server and and if files are there and we hav to bring that files to our system. After copying the files in our system we have to upload the data in the tables. I have scripts to load the... (2 Replies)
Discussion started by: nani1984
2 Replies

7. Shell Programming and Scripting

Bash script to Automate the Virtual Host creation process!!

Hi all, This is my sample code in /etc/httpd/conf.d/applications.conf file currently we are creating subdomain mannually for every new subdomain. I want to automate this process througs bash script , how its possible. <VirtualHost *:80> ServerName google.com ServerAlias google.com... (5 Replies)
Discussion started by: anishkumarv
5 Replies

8. Shell Programming and Scripting

Need help in creating a shell script to automate svnstats process

Hi, I am trying to create a shell script to automate the following process of getting svn stats:- Step1:- cd to checkout location. Note that the checked code have multiple modules in respective folders Step2:- Execute this command inside each module:- svn log -v --xml >... (0 Replies)
Discussion started by: d8011
0 Replies

9. UNIX for Dummies Questions & Answers

Automate sftp process using script

Hi, guys, I am trying to automate a sftp process using "expect" method (since the key authentication method is disabled in my company network, there is no helping it). In order to try, I type in the command manually: sftp @ > << EOF >cd >ls -l >EOF >Connecting to @servername password: ... (3 Replies)
Discussion started by: warmboy610
3 Replies

10. Open Source

Help with writing Shell Script to automate process using multiple commands

Hello! Need help to write a Linux script that can be run from windows using command/Cygwin/any other way. I am new to scripting, actually i am trying to automate server health check like free disk space, memory along with few services status, if any services is not running then start services ,... (7 Replies)
Discussion started by: Sayed Ibrahim
7 Replies
All times are GMT -4. The time now is 02:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy