Bash Script (tar + md) on Cygwin


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash Script (tar + md) on Cygwin
# 1  
Old 07-28-2015
Bash Script (tar + md) on Cygwin

Hi everybody,

First, I'm sorry for my bad english!

I have the following situation:

I have a Windows 2012 R2 with Cygwin installed. The Windows Server is used as a backup Server with Dell AppAssure installed. At the moment, AppAssure saves Backup Targets to a repository on his D. The repository size is about 3 TB. It's actually a 3 TB file. From this repository I create a so called "archiv" that is splitted in 2 folders.

Each folder should be copied to a LTO Tape. I want to do this job with TAR and MD with cygwin. I actually successfully could do this already:

Tape is = /dev/st0 (default)
With cd I first switch to the folder with the Folder "ApAs_Arc", which I want to write to tape.

Code:
# Export archiv to tape
# Rewind tape
mt -f /dev/st0 rewind
# Write folder to tape
tar -vcf /dev/st0 ApAs_Arc > export.log
----------------------------------------------------
# Import archiv to tape
# Rewind tape
mt -f /dev/st0 rewind
# Write folder to tape
tar -xvf /dev/st0 ApAs_Arc > import.log

So, until now everything that I wanted runs fine.

But here comes my problem. I would like to run this jobs as a script. You need to know and you'll see, I'm an absolutely newbie with that. I tried with google to find some tips, but I need more help.

I wrote two .sh Files (saved with notpad++ as .sh file).
First i start a .bat file as admin, that should run the following .sh script.
Code:
c:\cygwin64\bin\bash.exe -l C:\Technik\Skripts\BackuptoTape_ApAs_Arc_Copy.sh

With this code:
Code:
#!/bin/bash
# Write ApAs_Arc_2 to Tape
#-----------------------------------------------
# Datum Variable bestimmen
NOW=$(date)
# Startzeit in Logdatei schreiben
echo Start = $NOW >> /cygdrive/d/logs/export_ApAs_Arc_2.txt
# Band zurückspulen
mt -f /dev/st0 rewind
# Zeitpunkt des Finish wird in Log geschrieben
echo Finish = $NOW >> /cygdrive/d/logs/export_ApAs_Arc_2.txt

and after that i would run a .bat file (same procedure as above) that starts this script:
Code:
#!/bin/sh
# Write ApAs_Arc_2 to Tape
#-----------------------------------------------
# Datum Variable bestimmen
NOW=$(date)
# Startzeit in Logdatei schreiben
echo Start = $NOW > export_ApAs_Arc_2.log
# Ordner ApAs_Arc_2 in D: wird auf Tape geschrieben
tar -cvf /dev/st0 /cygdrive/d/ApAs_Arc_2
# Zeitpunkt des Finish wird in Log geschrieben
echo Finish = $NOW > export_ApAs_Arc_2.log

Well, my problem is, that it doesn't work Smilie. Yeah i know very good information. I get a cmd prompt, so I see the bat file is started. But that's all. No data is copied and no log file is written...

Sorry for my newbie question but I really would be thankful for your help.

Thanks

fibra3000
# 2  
Old 07-28-2015
Does the tape device start? Try to run the script with the option -x set. Are you sure you want it run by sh, not bash as in the other script?

Last edited by RudiC; 07-28-2015 at 05:34 AM.. Reason: typo
# 3  
Old 07-28-2015
Hi RudiC,

Thanks for your answer.

You mean like that?

Code:
c:\cygwin64\bin\bash.exe -x C:\Technik\Skripts\BackuptoTape_ApAs_Arc_Copy.sh

Actually i tried just to run it as sh first, then as bash because i thought probably that's the problem... so should I run it as bash?

And your last question, no the device doesn't start like that. Only when i manually enter the command in the cygwin terminal.
# 4  
Old 07-28-2015
What's the output when running it with -x ?
# 5  
Old 07-28-2015
It doesn't change anything. I got the same result as before.
# 6  
Old 07-28-2015
Hmmm - and what do you want us to work upon? My crystal bowl for example is a bit misty, today.
# 7  
Old 07-28-2015
1. Is the .sh File basicly correct like that, also with the .bat file to start it? Or do you see any possible failures?
What could be the problem that, there is no log file written?
These are the main questions...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to send mail tar.gz has attachment using cygwin?

Hi I am using cygwin in windows i need to send mail has attachment which was in tar.gz format i was using this command to send mail. I can able to send mail but attachment was not happening Is there any free email client to send mail has attachment which support tar file using cygwin... (15 Replies)
Discussion started by: ranjancom2000
15 Replies

2. UNIX for Beginners Questions & Answers

Using BATCH to call a BASH script on CygWin

I am trying to use a batch file to automatically execute a bash script with no luck this far. The batch script looks like this: C:\Cygwin64\bin\bash test.sh I have also tried this: C:\Cygwin64\bin\bash "C:\Cygwin64\bin\test.sh" Needless to say that the windows box has Cygwin... (7 Replies)
Discussion started by: Xterra
7 Replies

3. UNIX for Dummies Questions & Answers

Bash on CygWin

I am using CygWin to run a bash file but I am getting weird results. #!/bin/bash mkdir CLEANDATA mv *FASTA CLEANDATA cd CLEANDATA ls echo "COMPLETE" And this is what I get $ ./Pipe.txt ./Pipe.txt: line 5: $'ls\r': command not found COMPLETE Moreover, the new folder is... (1 Reply)
Discussion started by: Xterra
1 Replies

4. Shell Programming and Scripting

Bash script - cygwin (powershell?) pull from GitHub API Parse JSON

All, Have a weird issue where i need to generate a report from GitHub monthly detailing user accounts and the last time they logged in. I'm using a windows box to do this (work issued) and would like to know if anyone has any experience scripting for GitAPI using windows / cygwin / powershell?... (9 Replies)
Discussion started by: ChocoTaco
9 Replies

5. Shell Programming and Scripting

Cygwin bash script to unmount and mount an XP partition

As stated, I am looking into keeping my backup drive unmounted in normal windows use. Partly this is to address threats like cryptolocker. Since one of my backup drives is an internal drive, it will not likely afford any protection from such a threat. I am thinking of adding code to my rsync script... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

6. Windows & DOS: Issues & Discussions

run cygwin bash script from notepad++

I'm using Notepad++ to edit my BASH scripts and using CYGWIN to run them from Windows7. In Notepad++ there is a 'Run' capability. How do I get this to run my scripts directly without having to enter the script name from the Cygwin command line? (3 Replies)
Discussion started by: millsy5
3 Replies

7. Shell Programming and Scripting

BASH: Script jams Cygwin to 100% CPU -

I'd like to streamline the code more than a bit to get it to run faster. There's a thread about this and related issues of mine on the Cygwin mailing-list, but I want to eliminate any chances it might just be inefficient/inelegant/crappy code. A previous run of the same script on both Cygwin and... (6 Replies)
Discussion started by: SilversleevesX
6 Replies

8. UNIX for Dummies Questions & Answers

Cygwin bash script and read command

Hello everyone, I am struggling a bit with a batch script that I need to run in cygwin. I work in winXP and I had to write some awk scripts to do some file manipulation, and now I would like to automate the process by just running a batch file so that my colleagues can use it easily. Now, the... (2 Replies)
Discussion started by: Teroc
2 Replies

9. UNIX for Dummies Questions & Answers

How to use cygwin to run bash script

Hi, all, I try to run a quite simple bash script mytest.sh in cygwin, it's content is: #!/bin/bash echo "It is my first bash shell" there are three lines in the script. The second line is blank line. When I run it use command: bash c:/mytest.sh, ... (6 Replies)
Discussion started by: Jenny.palmy
6 Replies

10. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies
Login or Register to Ask a Question