File Backup - TAR help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Backup - TAR help
# 1  
Old 08-20-2010
File Backup - TAR help

Hi,

Another rookie here.

I have a script I am developing to backup files from various directories onto a windows machine.

Script description:
- mv files from various directories
- tar all files in that directory
- export to windows server for safe keeping, external backups.

The part I am stuck with is how TAR can determine which files in the directories are older than 2 days, then how to move them into a different directory which I can TAR then export.

I have been trying to use the find command as follows but I am inexperienced and haven't found google to be helpful yet.
Code:
find $BACKUPDIR1/* -mtime +2 -exec tar zcvf {}.tgz

Any thoughts?

Last edited by vbe; 08-20-2010 at 11:04 AM.. Reason: code tags please
# 2  
Old 08-20-2010
If you are trying to create separate tar files then try the following,

Code:
find ./t/* -mmin -10 -exec tar zcvf {}.tgz {} \;

first argument to find is path, you dont have to give * anyway.
# 3  
Old 08-20-2010
I think its the way you are naming your filename. "The filename can include wildcard characters (*,?, and []) but these characters must be quoted."

Sobell,Mark. A Practical Gude to Linux Commands, Eitors, and Shell Programming. 2010. page 690.
# 4  
Old 08-20-2010
appreciate the help, quick thought as I have realised I am doing something wrong.

Can I pass the results of find into the mv command in the same way I was hoping to do with the tar

Then i only need to TAR 1 file, and that filename won't changed (well add timestampt but thats easy).

something like:

find "all files in these directories" -mtime +2 -exec mv {} /"tar directory"
tar zcvf "tar directory"

Last edited by mcclunyboy; 08-20-2010 at 02:34 PM..
# 5  
Old 08-21-2010
Code:
find /PATH -type f -mtime +2 -exec mv {} /TAR_directory \;
tar zcvf mcclunyboy.tar.gz /TAR_directory

# 6  
Old 08-21-2010
I was almost there, just needed reassurance

We have a disk space issue on a db server I am hoping to use this to copy out backup files, it has to be better than just deleting them like we do at the minute.

I appreciate your help, my apologies for the missing code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX Tar file backup

I want to create a tar file that backup all my recent work. I have no idea how Tar file works and I am new to Unix Please help (1 Reply)
Discussion started by: GGBEASTBOI
1 Replies

2. AIX

how to take tar backup of the contents of a file

Hi I have a file named files.2.backup which holds the location of some directory and file i,e $ cat files.2.backup /d01/app/oracle/product/7.3.2/dbs/fortest_syst_01.dbf /d01/app/oracle/product/7.3.2/dbs/fortest_temp_01.dbf /d01/app/oracle/product/7.3.2/dbs/fortestdata_01.dbf... (5 Replies)
Discussion started by: sumanbangladesh
5 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

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

5. Filesystems, Disks and Memory

Tar file from Linux server to PC for backup

I have a Linux email server, I want to backup all /home /var... by tar command and copy to my PC for backup everyweek. The Linux serve rhave ftp function. Is there any program to help backup my file? any url welcome many thank. (8 Replies)
Discussion started by: zp523444
8 Replies

6. 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

7. Shell Programming and Scripting

How to exclude file in tar backup?

I am taking a backup of area with the following command:- tar -cf -./* |/usr/contrin/bin/gzip >xxx.tar.gz. The area contains following files :- xxxx yyyy zzzzz asdaD DASdD WQWEE I want to backup all the files except yyyy from the following area. I checked manual page of tar but I... (2 Replies)
Discussion started by: kamlesh_p
2 Replies

8. UNIX for Dummies Questions & Answers

tar backup problems

Im trying to use tar to backup the os directories. I have a file called bdirs which contains a list of the directories that im trying to backup: /bin /dev /devices /etc /export /home /kernel /lib /local /mnt /opt /platform /proc /sbin start /usr /var /vol (3 Replies)
Discussion started by: blakmk
3 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