Create an incremental tar


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Create an incremental tar
# 1  
Old 10-09-2014
Create an incremental tar

Hello,

I need to create a tar file with a list of files from a directory.
The directory has about 1000+ files of which I only need to create a tar ball of 150 files. The 150 files I need in the tar ball do not have common names or a common start letter.
No two file names match, example: 1st file name can be metrics.txt, 2nd file name can be avaerage,txt . etc ......

I need to know if I can make use of while or for loop and keep adding file to the tar ball.
So I would like to do something like:
1) put all the 150 file names into a list.txt
2) go to the directory where these files are available
3) write a while or for loop
Code:
while read n
do
<look for the file and add to the tar ball>
done < list.txt

Is this something achievable or is the best way to achieve is:to copy the 150 files into another directory and then tar that directory.

Can some one tell me the best approach.

thanks,
# 2  
Old 10-09-2014
What is your system? Some versions of tar have options for this.

Another option is timestamps. Keep the newest timestamp when making your last backup, then only add files newer than the file pointed to by -N. Both of these would avoid a giant loop running tar hundreds of times -- which is a bad idea since tar is not efficient used that way.
# 3  
Old 10-09-2014
Put complete names in the file like a relative path from a starting directory.
Code:
./path/to/fname

Or a full path
Code:
/directory/path/to/fname

This is efficient in that it invokes tar once. And simply writes to the current end of the tar file. The tarfile must exist for this work.

Code:
my_tar=/tmp/mytar.tar
touch $my_tar                      # create the file if needed
cd /starting/directory
tar -rvf $my_tar `cat /path/to/list_of_files.txt`

tar usually has a -u option (update). Try to avoid it, because it is sloooow. -r is a simpler way to keep the most recent copy of a file.

Let's say you want files just modified in the last 24 hours, here all put together.
Code:
cd /starting/directory
find . -mtime -1 > /path/to/list_of_files.txt
my_tar=/tmp/mytar.tar
touch $my_tar                      # create the file if needed
tar -rvf $my_tar `cat /path/to/list_of_files.txt`

# 4  
Old 10-09-2014
You can untar to a parallel subtree and diff/cmp to find new bits.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create Tar ball

Hi Team, Following unix command is throwing error. Can anyone please help me to fix the issue? tar -cvf /aa/bb/cc/tarball1.tar /x/y/z1/abc.ksh /x/y/z2/pqr.txt /x/y/z3/lmn.tmp Error message thrown: tar: Removing leading `/' from member names OS: uname -a Linux xyz... (1 Reply)
Discussion started by: kmanivan82
1 Replies

2. Shell Programming and Scripting

Incremental Backup using tar for more than one path

Hi everyone; I need to create a shell script for full and incremental backup purposes. for incremental backup only for one folder (test1) located in /home/test1 syntax below works fine and have no problem: tar -cvf /home/backup/backup-0.tar.gz -g /home/test1/test.snar /home/test Problem is here... (5 Replies)
Discussion started by: momed131
5 Replies

3. UNIX for Dummies Questions & Answers

Create Tar files

Hi, the folder /home/nandy/test will have two files called notepad1 nodepad2 when i issued /home/nandy/test> tar -cvf componse.tar ./notepad1 ./notepad2 and no error /home/nandy/test> tar -cvf nan.tar . --> this creates nan.tar with the below message nan.tar same... (1 Reply)
Discussion started by: Nandy
1 Replies

4. Shell Programming and Scripting

Create tar file

Following are the list of files available in the dataout directory a1.txt.gz a2.txt.gz b3.txt.gzStep 1: now the tar file needs to be created as follows. tar -cvf ab.tar *.gzAll the files with extn .gzg has to be bundled in the tar file. Once the tar file is created, the files which are... (9 Replies)
Discussion started by: kmanivan82
9 Replies

5. UNIX for Dummies Questions & Answers

How to create rpm from tar.gz?

I m planning to use puppet to implement organizational linux hardening policies across the linux servers. To begin with i have downloaded. puppet-2.7.1.tar.gz and tried some basic configuration to get start with puppet. Now i want to roll out the puppet but before that i would like to make... (7 Replies)
Discussion started by: pinga123
7 Replies

6. UNIX for Advanced & Expert Users

Do incremental backup without tar files up

I'm trying to do a incremental backup for a big NFS. Since space is not an issue, I don't want to compress them or end up with a big tarball for full backup( and a series of small tarballs for incremental backup). Basically I want the TAR backup/restore functionality but not TAR files up.... (3 Replies)
Discussion started by: overmindxp
3 Replies

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

8. HP-UX

tar says: cannot create

Hello, I'm quite new to HP-UX and I stumbeled upon some strange behaviour from tar. I have a script like this: find -mtime $days -type f|xargs tar cvf tarfile.tar and it make me a tar file with files that has been changed in $days. When i run 'tar tf tarfile.tar' it give me output like... (5 Replies)
Discussion started by: oey2000
5 Replies

9. SCO

Incremental Backup using TAR in sco Openserver 5.0

Incremental Backup using TAR in sco Openserver 5.0 Dear all I am using sco openserver 5.0. I wanted to take backup of two folder (each 600 MB size) with lot of files. I used to take backup using tar command daily using a script. But the same takes more time. Is there any way to take backup... (0 Replies)
Discussion started by: jamcalicut
0 Replies

10. 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
Login or Register to Ask a Question