How to handle files in use during Tar?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to handle files in use during Tar?
# 1  
Old 07-07-2010
Bug How to handle files in use during Tar?

How you do usually deal with files in use during a backup?
Is there a option to let TAR skip opened files?
Or notify me an opened file is tar'ed?

What's the best practice?

Thanks
This User Gave Thanks to overmindxp For This Post:
# 2  
Old 07-08-2010
AFAIK, there is no such option.

But there should be some best method to achieve this, am also waiting along with you for some experts to answer us this. Good question anyway.
# 3  
Old 07-08-2010
AFAIK, tar doesn't care about open files anyway. It just cares about the data associated with a file. And in order to get a clean state (no process writing a file while it's being read) we usually split the VG mirror, mount it on a different machine, and run the backup from there. Once it's done we re-sync the mirror with the active part.
# 4  
Old 07-08-2010
I'm sure there are people who can improve on this.
Code:
#!/bin/ksh                      
list=`ls x*`                    
i=0                             
for file in $list               
do                              
        echo $file              
        fuser $file             
        if [ $? = 0 ]           
        then                    
         if [ i -eq 0 ]         
         then                   
          tar cvnf y2.tar $file 
          i=1                   
         else                   
          tar uvnf y2.tar $file 
         fi                     
        else                    
          echo $file in use     
        fi                      
done

I think that the u option on the second tar statement can by replaced with r.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed on Perl Script to Handle Log files that are rotated using logrotate

Hello all, I am working on a perl script which will read weblogic logfile and send the error messages to Zenoss Monitoring tool. At present the script works and it can able to send the error messages to Zenoss. The problem comes when the logrotate has been applied to the weblogic log file. At... (3 Replies)
Discussion started by: kar_333
3 Replies

2. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

3. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

4. UNIX for Dummies Questions & Answers

Grep alternative to handle large numbers of files

I am looking for a file with 'MCR0000000716214' in it. I tried the following command: grep MCR0000000716214 * The problem is that the folder I am searching in has over 87000 files and I am getting the following: bash: /bin/grep: Arg list too long Is there any command I can use that can... (6 Replies)
Discussion started by: runnerpaul
6 Replies

5. UNIX for Dummies Questions & Answers

Awk cannot handle more than 30 files

I trying to search for lines with multiple search criterias in an archive of zipped files. But awk seems to have a limit. Any idea how to fix it? I'm on a sun solaris system. Here is my search string: gzcat -r *200808* | awk -v 'substr($0,50,11)=="11095512309" ||... (3 Replies)
Discussion started by: HugoH
3 Replies

6. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

7. Shell Programming and Scripting

[Beginner] Handle Files

Hi, How can I check if a text files is empty? (With Bash Shell) (5 Replies)
Discussion started by: DNAx86
5 Replies

8. Shell Programming and Scripting

FTP - To handle error while transferring files

Hi, I had written an FTP script where in I loop through the directories and transfer the files from each and every directory of Windows to UNIX. Now the problem is when 1. The connection is unable to be established I should return some error codes 2. When there is some system... (1 Reply)
Discussion started by: mahalakshmi
1 Replies

9. UNIX for Dummies Questions & Answers

Can solaris's Zip/Unzip handle Winzip Version 10.0 Files?

I understand that this version of Winzip allows 129-bit AES encryption and passwords. Can Solaris handle that yet? (2 Replies)
Discussion started by: BCarlson
2 Replies

10. UNIX for Advanced & Expert Users

Untaring *.tar.tar files

Hi all, How to untar a file with .tar.tar extension. A utility that i downloaded from net had this extension. Thanks in advance, bubeshj. (6 Replies)
Discussion started by: bubeshj
6 Replies
Login or Register to Ask a Question