nixCraft Linux / UNIX / Shell Scripting Forum

nixCraft

Linux / UNIX Tech Support Forum

backup using tape

This is a discussion on backup using tape within the Novell Suse / OpenSuse forums, part of the Linux Distribution category; hi i need to make some scripts: 1) a script that will add an zip archive each week to a ...


Register free or login to your account to remove all advertisements.

Go Back   nixCraft Linux / UNIX / Shell Scripting Forum > Linux Distribution > Novell Suse / OpenSuse

Linux answers from nixCraft.


Novell Suse / OpenSuse Discussion about Novell Linux or OpenSuse Linux related problems.

Closed Thread

 

Thread Tools Display Modes
  #1 (permalink)  
Old 26th November 2009, 09:25 PM
Junior Member
 
Join Date: Nov 2009
OS: openSuSE
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
bennyhll is on a distinguished road
Default backup using tape

hi
i need to make some scripts:
1) a script that will add an zip archive each week to a tape.
2) a script that will tell when there is no room on the tape to put archives
3) a script that will search/extract a specific archive from that tape, when requested.

can you help me, please ? i'm quite a newbie on scripting. I tried 2 times for script no 1), but none of it seems to work right because when i try to extract, nothing is where it sould be or cannot be extracted. These are my scripts:

counter - is a file in my scripts directory where i store the backup track number on tape
mailul - is a file in my scripts directory where i store mail body to be sent

TRY no 1:

#!/bin/sh
#-- Declarare variabile----------------------------
data=`date +%d-%m-%Y`;
cale=/BACKUP;
src=/home/journaling/Maildir/cur
t=`cat counter`;
num_file=$data-$t

#-- Arhivare ------------------------------------
/usr/bin/zip -r -P password /BACKUP/$num_file.zip $src
count=0

#-- First time backup ----------------------------
if [ $t -eq 1 ]; then
echo " S-a creat arhiva $num_file.zip " >> $cale/mailul;
echo " Initializez primul backup pe banda " >>$cale/mailul;
mt -f /dev/st0 tell;
nice -19 dd if=$cale/$num_file.zip of=/dev/nst0;
mt -f /dev/st0 weof 1;
>counter;
echo "1" >> counter;
echo " In data `date +%d-%m-%y` ,ora `date +%T` backup created " >> $cale/mailul
#-- Next time backup ----------------------------
else
mt -f /dev/nst0 eod;
nice -19 dd if=$cale/$num_file.zip of=/dev/nst0;
echo " In data `date +%d-%m-%y` ,ora `date +%T` backup $t created on tape " >> $cale/mailul
(( t += 1 ));
mt -f /dev/st0 weof $t;
>counter;
echo "$t" >> counter;
fi

#-- Send mail, create log -----------------------------------
cat $cale/mailul| mail mymail@mydomain -s "Journaling BACKUP"
cp $cale/mailul $cale/log-$num_file

#-- empty mail body ----------------------------------------
>mailul


TRY no. 2:


#!/bin/sh
#-- Declarare variabile ------------------------------------------------
data=`date +%d-%m-%Y`;
cale=/BACKUP;
t=`cat counter`;

#-- Lock sa nu se suprapuna backup-urile ------------------------------
if [ -f /tmp/backup.lock ]; then
echo "locked!"
exit;
fi
date>/tmp/disk_to_tape.lock

#-- Arhivare-----------------------------------------------------
/usr/bin/zip -r -P password /BACKUP/$data.zip /home/costin
count=0

#-- Primul backup de pe banda -----------------------------------
if [ $t -eq 0 ]; then
for f in $data;
do echo " S-a creat arhiva $data.zip " >> $cale/mailul;
echo " Banda este goala, initializez primul backup " >>$cale/mailul;
nice -19 tar cf /dev/nst0 /BACKUP/$data.zip;
mt -f /dev/st0 weof 1;
>counter;
echo 1 >> counter;
done
if [ $count -eq 1 ]; then
echo " In data `date +%d-%m-%y` ,ora `date +%T` s-a realizat backup-ul si a fost mutat pe tape drive " >> $cale/mailul
else
>mailul;
echo " Verifica banda, nu s-a efectuat backup-ul ! " >> $cale/mailul;
echo " `date +%d-%m-%y` " >> $cale/mailul;
echo " `date +%T` " >> $cale/mailul;
fi

#-- Backup-uri adaugate pe banda ------------------------------------
else
for f in $data;
do echo $count >> $cale/mailul;
echo "Adaug backup-ul $t pe banda existenta" >> $cale/mailul
mt -f /dev/nst0 eom;
nice -19 tar cf /dev/nst0 /BACKUP/$data.zip;
(( t += 1 ));
mt -f /dev/st0 weof $t;
(( count += 1));
>counter;
echo "$t" >> counter;
done
if [ $count -eq 1 ]; then
echo " In data `date +%d-%m-%y` ,ora `date +%T` s-a realizat backup-ul si a fost mutat pe tape drive " >> $cale/mailul
else
>mailul;
echo " Verifica banda, nu s-a efectuat backup-ul ! " >> $cale/mailul;
echo " `date +%d-%m-%y` " >> $cale/mailul;
echo " `date +%T` " >> $cale/mailul;
fi
fi

#-- Remove lock, send mail, create log ----------------------------
rm -f /tmp/disk_to_tape.lock
cat $cale/mailul| mail mymail@mydomain -s "Journaling BACKUP"
cp $cale/mailul $cale/log-$data

#-- golire fisier de mail pentru urmatoarea operatie ---------------
>mailul
  #2 (permalink)  
Old 27th November 2009, 03:59 PM
nixcraft's Avatar
Never say die
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash, Perl, Python
Posts: 3,294
Thanks: 13
Thanked 411 Times in 304 Posts
Rep Power: 10
nixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond repute
Default

Please do not post same message twice. See your first thread.
__________________
Vivek Gite
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Do you run a Linux? Let's face it, you need help!
Cricket & IPL News Blog
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
HP DAT 72 tape drive not recognized Dano Ubuntu / Debian 12 30th October 2009 01:09 PM
Fedora Linux Tape Drive Device Name and Backup Commands madmacher Linux software 1 27th November 2008 10:57 PM
tar tape command example tom Getting started tutorials 0 5th June 2007 09:36 AM
UNIX list a backup tape contents chiku Getting started tutorials 0 27th April 2007 04:46 PM
Openbsd Howto backup data on tape - tutorial raj All about FreeBSD/OpenBSD/NetBSD 1 20th December 2006 01:44 AM


All times are GMT +5.5. The time now is 08:27 AM.


Powered by vBulletin® Version 3.8.6 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40