How to avoid TAR of directory with no permissions?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to avoid TAR of directory with no permissions?
# 8  
Old 03-18-2013
\T\h\a\n\k\s \! Smilie
# 9  
Old 03-19-2013
Hi,

Thanks for the reply. But let me put my issue clear here;
1. When i TAR Directory with no permissions a TAR file is created containing empty directory.
2. now during untar i can retrieve this directory but with no contents. Contenets have not been tar due to no permissions.
3. Ideally it should have tar the directory since it had no permissions.
4. In order to clean this TAR i need to remove tyhis directory from the same TAR file.
5. Using PAX gives me same command error that permission denied and nothing changes.

Code:
 
find /u01/appl/t1elkpe/pst/max/SCRIPTDIR/fd/ \! \( -type d -perm 0 -prune \) | pax -w > 20130314154440.tar
find: cannot read dir /u01/appl/t1elkpe/pst/max/SCRIPTDIR/fd/: Permission denie

Can you please highlight how can i delete unwanted directories from my TAR files?

Thanks and Regards
Rajan Gupta
# 10  
Old 03-19-2013
One wonders why you have a directory with no permissions. I suppose, if you can't see in it, then you can't back it up and you can't extract it anyway. As backups need to be able to set permissions when they are restored, this is a process for the superuser really.

If you have superuser access, then it seems to work fine:-
Code:
RBATTE1 @ /usr/home/RBATTE1/uf>sudo find . -exec ls -ld {} \;
drwxr-xr-x   3 RBATTE1  SYSSUP          256 19 Mar 09:29 .
d---------   2 RBATTE1  SYSSUP          256 19 Mar 09:31 ./dufdir
-rw-r--r--   1 RBATTE1  SYSSUP            5 19 Mar 09:31 ./dufdir/file3
-rw-r--r--   1 RBATTE1  SYSSUP            6 19 Mar 09:29 ./file1
----------   1 RBATTE1  SYSSUP            4 19 Mar 09:29 ./file2
RBATTE1 @ /usr/home/RBATTE1/uf>sudo tar -cvf ../uf.tar .     
a .
a ./dufdir
a ./dufdir/file3 1 blocks
a ./file1 1 blocks
a ./file2 1 blocks
RBATTE1 @ /usr/home/RBATTE1/uf>sudo rm -r *
RBATTE1 @ /usr/home/RBATTE1/uf>sudo find . -exec ls -ld {} \;
drwxr-xr-x   2 RBATTE1  SYSSUP          256 19 Mar 09:35 .
RBATTE1 @ /usr/home/RBATTE1/uf>sudo tar -xvf ../uf.tar 
x .
x ./dufdir
x ./dufdir/file3, 5 bytes, 1 tape blocks
x ./file1, 6 bytes, 1 tape blocks
x ./file2, 4 bytes, 1 tape blocks
RBATTE1 @ /usr/home/RBATTE1/uf>sudo find . -exec ls -ld {} \;
drwxr-xr-x   3 RBATTE1  SYSSUP          256 19 Mar 09:29 .
d---------   2 RBATTE1  SYSSUP          256 19 Mar 09:31 ./dufdir
-rw-r--r--   1 RBATTE1  SYSSUP            5 19 Mar 09:31 ./dufdir/file3
-rw-r--r--   1 RBATTE1  SYSSUP            6 19 Mar 09:29 ./file1
----------   1 RBATTE1  SYSSUP            4 19 Mar 09:29 ./file2
RBATTE1 @ /usr/home/RBATTE1/uf>

Is this an option?


Robin
Liverpool/Blackburn
Uk
# 11  
Old 03-19-2013
Hi,

I am designing a script that worlks like recycle bin funtcionality in windows.
So if you accidently delete a directory which has no permission you would not able to do it and the tar file created should not contain any traces of this directory.

I am testing a senario. below are the cronological events i am testing for my script.

1. i created a directory with contents. change permissions to 0.
2. tried deleting it. TAR file contain the empty directory with the same name.
3. Now if i try to extract the tar and lets suppose the original directory has regained it access then this empty directory replaces the directory with contents.

So i am trying to identifyu this directory and remove from the tar that is created.

Can you please help me in this.

Best Regards,
Rajan Gupta
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

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: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

2. Shell Programming and Scripting

Directoy Size - avoid cannot read directory

Hello, I need to write a script to check directory size on a linux server. I do not have access to some directories Inside the directory tree so I've got some warning in the output that say : du : cannot read directory .... Could you please help me. I did try Inside of my script to... (2 Replies)
Discussion started by: Aswex
2 Replies

3. UNIX for Dummies Questions & Answers

Directory permissions

i have an application that writes to a directory. let's call the directory: /var/app/ the permissions of this directory is: drwxrwxr-x Now the files that the application creates in this directory usually dont have read permissions for others. i know there's something called... (3 Replies)
Discussion started by: SkySmart
3 Replies

4. Solaris

Directory Permissions for 2 users on 1 directory

we want to allow user to FTP files into a directory, and then the program (PLSQL) will read and process the file, and then move the file to other directory for archiving. the user id: uftp1, group: ftp the program run in oracle database, thus have the user Id: oraprod, group: dba how to... (2 Replies)
Discussion started by: siakhooi
2 Replies

5. Shell Programming and Scripting

Checking directory permissions on UNIX directory

Hi, How do i check if I have read/write/execute rights on a UNIX directory? What I'm doing is checking read access on the files but i also want to check if user has rights on the direcory in whcih these files are present. if then...... And I check if the directory exists by using... (6 Replies)
Discussion started by: chetancrsp18
6 Replies

6. UNIX for Advanced & Expert Users

How to rsync or tar directory trees, with hidden directory, but without files?

I want to backup all the directory tress, including hidden directories, without copying any files. find . -type d gives the perfect list. When I tried tar, it won't work for me because it tars all the files. find . -type d | xargs tar -cvf a.tar So i tried rsync. On my own test box, the... (4 Replies)
Discussion started by: fld2007
4 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. Cybersecurity

Permissions ( to avoid unwanted things )

I want to make an automated system to compile & run the source codes from different persons and to tell if the output is the same with the standard one(wich is given by me). Ok, this is quite simple, but the tricky part is,how do I avoid the "bad intentions" that may result from running those... (2 Replies)
Discussion started by: spiriad
2 Replies

9. UNIX for Dummies Questions & Answers

permissions of a directory

Read and write bits make sense for a directory but what about the execute permission bit What does that imply?Is it just a filler? Saurabh (3 Replies)
Discussion started by: smehra
3 Replies

10. Shell Programming and Scripting

determine owner directory permissions from within the directory

From within a directory, how do I determine whether I have write permission for it. test -w pwd ; echo ? This doesn't work as it returns false, even though I have write permission. (4 Replies)
Discussion started by: Sniper Pixie
4 Replies
Login or Register to Ask a Question