Making Tar of directory and tar file is going to be placed


 
Thread Tools Search this Thread
Operating Systems AIX Making Tar of directory and tar file is going to be placed
# 1  
Old 02-19-2016
Making Tar of directory and tar file is going to be placed

Quick question,

is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?)

sample:

Code:
/opt/freeware/bin/tar -cvf -  /oracle | gzip > /oracle/backup.tgz

will the tar file backup.tgz also include backup.tgz ?

i tried searching for answer but did not find a reasonable answer.
# 2  
Old 02-19-2016
Try:
Code:
tar --exclude backup.tar.gz -acf backup.tar.gz *

hth
# 3  
Old 02-19-2016
Thanks SEA, so it is important to exclude the file, which means that Tar backup will include the newly backuped tar file into tar

so, let try it this way,
put the file in a directory called /nobackup

Code:
tar --exclude /oracle/backup/ -cvf -  /oracle | gzip > /oracle/backup.tgz

am i right ?

Table 1. Required Flags
Required Flags Description
-c Creates a new archive and writes the files specified by one or more File parameters to the beginning of the archive.
-f Archive Uses the Archive variable as the archive to be read or written. When this flag is not specified, the tar command uses a system-dependent default file name of the form /dev/rmt0. If the Archive variable specified is - (minus sign), the tar command writes to standard output or reads from standard input. If you write to standard output, the -c flag must be used.
-v Lists the name of each file as it is processed. With the -t flag, -v gives more information about the tape entries, including file sizes, times of last modification, User Number (UID), Group Number (GID), and permissions.


what does -a in tar parameter stand for ?
thanks
# 4  
Old 02-19-2016
Quote:
Originally Posted by filosophizer
is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?)
Yes, that is possible - it is just not worth the hassle.

Quote:
Originally Posted by filosophizer
will the tar file backup.tgz also include backup.tgz ?
Without taking precautions: yes, it will, although in an incomplete and unusable form.

Note that this here is the AIX-forum and hence i suppose you use AIX as your OS. The AIX tar (as opposed to the GNU tar) does NOT know the suggested "--exclude" option , because it is not required by POSIX. This means the suggested solution will not not work in AIX as long as you are not willing to install a lot of (GNU-)software.

You can achieve the same using some find-statement to produce a list of file names in the directory minus the one with the name of the tar-file itself and feed that into tar. But, frankly: wouldn't be writing the tar-file elsewhere and finally moving it be a lot easier? In principle it is possible to walk from Europe to China on your hands, but: an airplane will get you there as well and it will be less tedious.

If you think about backing up your database that way, be warned: tar follows the ustar-standard and this limits the single input file to 8G of size. Therefore tar is a poor tool for database backups. (btw: cpio does the same). For the backup of Oracle databases consider using the Oracle-framework called RMAN and some backup tool. You need it anyway because you need to constantly shovel the archive logs off the machine when the DB is running.

I hope this helps.

bakunin
# 5  
Old 02-20-2016
I think that /oracle is not a database but an ORACLE_HOME hopefully Smilie

Nevertheless you might want to consider using pax if you don't have GNU tar
Code:
cd /oracle
pax -w -f backup.tar -s',backup.tar,,' .
cd -

Will shall change directory to /oracle and create archive of current directory (.) using the pax substitute to exclude the backup.tar file itself. After it is done we shall return to previous working directory (-).

You will be able to extract the tar file using tar or pax on any operating system, but limits Bakunin mentioned still apply.


Hope that helps
Regards
Peasant.
# 6  
Old 02-20-2016
If you use pax archive format when using the pax utility, the file size limits from the tar and cpio archive formats are removed. So with:
Code:
cd /oracle
pax -w -x pax -f backup.pax -s',backup.pax,,' .
cd -

files of any size can be archived as long as there is enough space in the filesystem where the archive is being written to hold the entire archive.

This might even work without the -x pax option; the standards don't specify which archive format is used when creating an archive when the -x option is not specified on the command line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Tar - pre-checking before making the Tar file

Coming from this thread, just wondering if there is an option to check if the Tar of the files/directory will be without any file-errors without actually making the tar. Scenario: Let's say you have a directory of 20GB, but you don't have the space to make Tar file at the moment, and you want... (14 Replies)
Discussion started by: filosophizer
14 Replies

2. UNIX for Dummies Questions & Answers

UNIX command to check if file name ends with .tar OR if the file is a tar file

Hello Team, Would you please help me with a UNIX command that would check if file is a tar file. if we dont have that , can you help me with UNIX command that would check if file ends with .tar Thanks in advance. (10 Replies)
Discussion started by: sanjaydubey2006
10 Replies

3. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

4. UNIX for Advanced & Expert Users

Move files while making a tar

I have the following folder structure code/f1/ code/lib/t1 code/lib/t2 code/lib/t3 code/lib/t3 code/lib_1/t1 code/exc I would like to create a tar with a folder structure below and I can use the following tar command f1 lib/t1 lib/t2 lib/t3 tar -cvf code.tar -C code f1 lib... (4 Replies)
Discussion started by: alpboys
4 Replies

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

6. UNIX for Dummies Questions & Answers

Making tar of a remote file system

Hello, I was asked by my boss to make a backup of one of our systems that is slated to be decommissioned. When I suggested if could tar the "/" directory he nodded and said that would do the trick, When I try and execute the command I get EOF error. I think it is because there is not enough... (2 Replies)
Discussion started by: mojoman
2 Replies

7. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

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

9. UNIX for Advanced & Expert Users

Tar utility (untar a .tar file) on VxWorks

Hi All Can someone pls guide me if there any utility to compress file on windows & uncompress on vxworks I tried as - - compressed some folders on windows ... i created .tar ( to maintain directory structure ) and compressed to .gz format. - on VxWorks i have uncompressed it to .tar... (1 Reply)
Discussion started by: uday_01
1 Replies

10. UNIX for Advanced & Expert Users

Does tar do crc checking on a tape or tar file?

Trying to answer a question about whether tar table-of-contents is a good tool for verifying tape data. (1 Reply)
Discussion started by: tjlst15
1 Replies
Login or Register to Ask a Question