1834328 Members
2736 Online
110066 Solutions
New Discussion

Tar Command

 
DK Raviraja
Occasional Advisor

Tar Command

Hello,

How to take backup only file from a folder.

Examle

I got a folder /u01/home/test
/u01/home/test/file1
/u01/home/test/file2
/u01/home/test/file3
/u01/home/test/dir1
/u01/home/test/dir2

I would like to use tar command only t take Backu of files in test folder. All sub directories shoudl not be backedup

Any Help ?

Thanks
Mera Bharath Mahan
3 REPLIES 3
Dan Hetzel
Honored Contributor

Re: Tar Command

Hi,

tar cvf ../tarfile $(lsf | grep -v "/" | sed 's/*//')

Make sure you put your tarfile at some other place to avoid "archiving the archive"
You need 'sed' to suppress the asterix given by 'lsf'

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
federico_3
Honored Contributor

Re: Tar Command


If you want to backup your data in a file you can use:

cd DIR
touch tarfile

tar cvf ./tarfile $(ls -p | grep -v "/")

if you want to backup in a tape :

tar cvf /dev/rmt/0m $(ls -p | grep -v "/")

Bye
federico




Sandor Horvath_2
Valued Contributor

Re: Tar Command

Hi !

try:
tar cvf backupfile $(ll | grep -v ^d | awk ' { print $NF } ' )

regards, Saa
If no problem, don't fixed it.