Backup help/advice using TAR


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Backup help/advice using TAR
# 15  
Old 01-09-2006
Quote:
Originally Posted by dangral
Maybe my eyes deceive me here, but isnt your code deleting the very files you just moved into $Archive?
Ummm.... depends on what you mean by that. It would be more accurate to say that it's deleting the original copies. So the end result is like a move operation. This is what the OP requested. I hope he uses another techique to back up the os.
# 16  
Old 01-10-2006
Guys, many thanks for your help here, it really is appreciated. I will have a go with your suggested work around.
And no we don't edit the script each day I was just filling a few parameters in to make it a bit more readable.
Thanks again I will post back the results to let you know how it goes.
# 17  
Old 01-10-2006
Sorry can you just explain the line -

(cd $Archive ; find . -type f )| xargs rm

I can see that you have copied the files into $Archive, along with its sub-directories. But then this line seems to be deleting everything in $Archive, ie what you have just created? Shouldn't it be looking in /big/file/collection and doing mtime +7 again??? Hopefully I have misunderstood. Also if you did that then potentially you could miss a file that was created between the copy and the delete?
Thanks.
# 18  
Old 01-10-2006
Whoa, I've never seen someone argue both for and against a change to one of my scripts before. No, it should not be looking in /big/file/collection. And, yes, if it did that, it would be broken, but not precisely for the reason you gave.

You want to get the list of names to delete from the Archive directory. You do not want to go back and get a second list of names from the main directory. If the files was copied to the Archive directory, it is clearly safe to delete the original. I hope that you are not creating files with older timestamps. But you sense a race condition and you're right. A file that was something like 6.999 days old during the first find might be 7.001 days old during the second find. Getting the list of files to delete from the Archive directory is the only secure thing to do. And it will be faster anyway...fewer files to look at; and no need to check timestamps.

When you put a command in parentheses, it is run in a subshell. That subshell will change the cwd to Archive and execute the find. Meanwhile, the parent shell continues to have it's own (unchanged) cwd. The xargs command inherits this cwd from the parent shell and passes the cwd on its offspring, which are the rm processes. So the rm processes will be affected by the original "cd /big/file/collection" while find command is affected by the "cd $Archive".

Maybe this is what was bothering dangral too. Using parentheses to spawn a subshell is a standard technique that goes back even to the old bourne shell in the 70's.
# 19  
Old 01-10-2006
Quote:
Originally Posted by Perderabo
Maybe this is what was bothering dangral too. Using parentheses to spawn a subshell is a standard technique that goes back even to the old bourne shell in the 70's.
Yes, I mistakenly did not take the subshell into account.
# 20  
Old 01-11-2006
Ah, I see. That makes sense. Fantastic it could just do the trick. I will give it a whirl and report back.
Many thanks once again.
# 21  
Old 01-11-2006
Excellent, it has certainly improved things. I ran a test with a subset of data, the old script processed it in 210 minutes. The new script with the above code in it ran in 70 minutes - fantastic.
Many many thanks for your help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Advice on a backup script, maybe one is out there already?

Hi, Not sure whether this is the right place to post it. I decided to post it here 'coz Advanced and Expert users will most likely have the answer to what I am looking for. I want to backup scripts that I have access to to a tar file file and zip it. At the moment I am creating a directory... (4 Replies)
Discussion started by: newbie_01
4 Replies

2. Red Hat

Backup and restore using tar

This will be covered elsewhere im sure but i just cant seem to find my exact issue. I want to backup my systems using tar, command is: tar -cjpf /backup /bin /etc /home /opt /root /sbin /usr /var /bootWhen i include the / directory it also tar's the /lib /sys /proc /dev filesystems too (and... (8 Replies)
Discussion started by: Tommyk
8 Replies

3. UNIX for Dummies Questions & Answers

Tar differential backup

I am backing up some data to an NTFS formatted backup drive. I have to preserve the Unix permissions of the data being backed up and therfore use backup into a tar file. I would like to backup the differnential data in the tar file similiar to how Rsync works so as to save on backup time as it... (1 Reply)
Discussion started by: jelloir
1 Replies

4. Filesystems, Disks and Memory

an advice regarding backup plan

Hi all i'm looking for good advice regarding backup plan becuase its first time to me handle large scale database expected to grow up 10000 - 20000 record per year with daily operations on it I'm working as sysAdmin in educational organization ( junior level ) with mixed OSes environment... (3 Replies)
Discussion started by: h@foorsa.biz
3 Replies

5. UNIX for Dummies Questions & Answers

Backup with tar

Hi friends, I am planning to backup my Solaris Servers to SAN storage using tar. Also palnning to automate the job using Crontab. Can anyone advise how to make the date change automatically everyday for backup. Pls correct me if I am wrong. Thanks (7 Replies)
Discussion started by: solaris5.10
7 Replies

6. Red Hat

tar backup on network

Hi all, i need to backup files on network from RHEL 4 machine tape drive is installed on solaris 10 machine and want ot use this using # tar cv /myfiles |ssh -l myuser myhost 'buffer -o /dev/rmt/0 " to backup these file but getting getting error " sh buffer not found ' even "buffer-1.19-1"... (2 Replies)
Discussion started by: ajays
2 Replies

7. Shell Programming and Scripting

tar - incremental backup

Hello everyone! I'm trying to make incremental tar archives of a folder for an example. On the box I use is UNIX AIX installed. I tried some sample codes I found on several web pages but with no success. Don't know what I'm doing wrong. Please write some sample code to make incremental tar... (0 Replies)
Discussion started by: Funky_ass
0 Replies

8. UNIX for Dummies Questions & Answers

Tar backup

I am trying to do a full system backup using tar. It then after maybe 12 or so hours comes up with tar: write error: unexpected EOF. I have thoroughly cleaned the drive and tried to use a different drive but it still gives me this error. Can someone help. I am on solaris 8. (1 Reply)
Discussion started by: TMashie
1 Replies

9. Filesystems, Disks and Memory

Using `tar` for a selective backup.

Hi all & anyone. I'm trying to selectively backup up some old Apache log files before they are removed from the system (Slackware box). Have created a file listing of what I want backed up ...Below is a portion of the file ./selectedbkup... (2 Replies)
Discussion started by: Cameron
2 Replies

10. UNIX for Advanced & Expert Users

tar backup

Hi all, I would like to append list of files to already taken tar backup file. can anybody help? last month backup : cd /accounts/11 tar -cvf monthback.tar * Now I want to add /accounts/12 to monthback.tar is it possible? Krishna (1 Reply)
Discussion started by: krishna
1 Replies
Login or Register to Ask a Question