How to write bash script for lvm snapshot?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to write bash script for lvm snapshot?
# 1  
Old 05-21-2013
Error How to write bash script for lvm snapshot?

Hi Team

I am trying to put together a nice small script to mount my lvm snapshot

Here are my objectives

1 Check whether snapshot is currently mounted. If so echo umount snapshot and exit from the script.
2 If it's not mounting, check whether the mount point exist, If so, create lvm snapshot and mount and exit

I managed to do the 2nd part of my objectives. However I am not too sure the good way to connect the 1st and 2nd part.

Here is my script with the 2nd part, but I need help with the first part.
Please help
Code:
#!/bin/bash -x

LVM_APP_SNAP_MOUNT="/sysmanage/lvm/snapshot/app"
LVM_APP_SNAP_VOL="2G"
LVM_APP_SNAP_NAME=LogVol01_SNAP
LVM_APP_FS="/dev/VG00/LogVol01"

elif [ -d "$LVM_APP_SNAP_MOUNT" ]
                then
        echo -e "Mount Point Exist" &&
        lvcreate -s -n "$LVM_APP_SNAP_NAME" -L "$LVM_APP_SNAP_VOL" "$LVM_APP_FS" &&
        mount  "$LVM_APP_FS"'_SNAP' "$LVM_APP_SNAP_MOUNT"


else    echo -e "Create Directory "\"$LVM_APP_SNAP_MOUNT\"" before continue"
fi


Last edited by Scott; 05-21-2013 at 12:55 AM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to write a value to a physical memory address in bash script?

How would I write a value to a physical memory address? I was able to read a physical memory address (for example, 0x400) using this line: dd if=/dev/mem count=4 bs=1 skip=$(( 0x400 )) But I get an error: dd: 'standard input': cannot skip to specified offset when I try to write using... (1 Reply)
Discussion started by: rabrandt
1 Replies

2. UNIX for Beginners Questions & Answers

How To Write my Bash Script To Automate it?

Hello guys, I need some help. I am new in bash and I don't know how to automate the following script. head -2 out1 > 1.fasta sed ‘1,2 d' out1 > out2 rm out1 head -2 out2 > 2.fasta sed ‘1,2 d' out2 > out1 rm out2 head -2 out2 > 3.fasta sed '1,2 d' out2 > out1 rm out2 .......... (3 Replies)
Discussion started by: dellia222
3 Replies

3. UNIX for Dummies Questions & Answers

Script to break up file (write new files) in bash

Hello experts, I need help writing individual files from a data matrix, with each new file being written every time there is a blank line: From this cat file.txt col1 col2 col3 6661 7771 8881 6661 7771 8881 6661 7771 8881 col1 col2 col3 3451 2221 1221... (6 Replies)
Discussion started by: torchij
6 Replies

4. Shell Programming and Scripting

How to write bash shell script for mentioned requirement?

Hi All, I am unable to write the script for the below requirement. Requirement: Main table dir_ancillary table contain three column "dir_ancillary.table_name"," dir_ancillary.text_file_name ", "dir_ancillary.Include" . This dir_ancillary contain undefined tables in the column... (2 Replies)
Discussion started by: Vineeta Nigam
2 Replies

5. Shell Programming and Scripting

Help to write bash script code

I am newbie to UNIX. I came across this exercise in one the books.Can anyone help me with this question?????? Write a short Bash script that, given the name of a file as an argument, reads the file name and creates a new file containing only lines which consist of one word. Here is an example... (4 Replies)
Discussion started by: krthknaidu
4 Replies

6. Homework & Coursework Questions

How to write script in bash.

I am very new to Linux/Unix. Kindly assist the following: I wish to write a bash shell script called how_many_to_go that calculates and prints the number of days, hours, minutes and/or seconds until the end of the current month (based on the output of the date command). Do ... (2 Replies)
Discussion started by: alobi
2 Replies

7. Filesystems, Disks and Memory

LVM snapshot question

Hi All, I am planning to do a LVM replicate to another server. Example : server1.foo.com has / , /boot , swap and few LVM partitions. All are in /dev/sda disk of size 80GB. /dev/sda5 is a LVM partition which has only one vg00 and it has 2 LV's (/var and /usr) and a SAN storage connected to... (0 Replies)
Discussion started by: rakrhn
0 Replies

8. Linux

LVM snapshot question

Hi All, I am planning to do a LVM replicate to another server. Example : server1.foo.com has / , /boot , swap and few LVM partitions. All are in /dev/sda disk of size 80GB. /dev/sda5 is a LVM partition which has only one vg00 and it has 2 LV's (/var and /usr) and a SAN storage connected to... (0 Replies)
Discussion started by: rakrhn
0 Replies

9. Shell Programming and Scripting

Can anybody write this bash script ?

hi, first congratulations on the nice forum! Can anybody write script, which can make copy of some or all files of the current directory in new directory (called "backups", which must be made in the current directory, if it's not already exist). And bring out a massage (report) with the count... (7 Replies)
Discussion started by: Cecko
7 Replies

10. Linux

How to extend lvm with snapshot ?

Hello all, Please guide me through this procedure. I am newbie. current status of my lvm is as following. /dev/myvg/lvm1 5 GB mounted /data /dev/myvg/lvm1_snap1 5 GB mounted /data_backup Now i want to extend the lvm it self with sanpshot then how should i go for it. ... (1 Reply)
Discussion started by: bryanabhay
1 Replies
Login or Register to Ask a Question