• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

How to Run "tar" command to tar all files/folders but EXCLUDE other folders

I have a folder on Unix (AIX) called: Peoplesoft. The owner of this folder is the user I login with: PSFT811. It has a ton of files and folder under it. I have been trying to run tar command to tar all files/folders under this directory and copy it over to another server. But I keep getting permission errors even though I"m the owner of the folder.

If found out that there are 3 folders under that "Peoplesoft" folder that has a different owner. I suspect this is why I get the permission errors when i try to copy.

I was told I could run the tar command and use a: "-X" parameter provide an "exclude list" and specify the folders I want to exclude from the tar copy.

But when I try to run the command I still get permission errors. I don't think I"m running it right. See attached. Please advise on the correct tar command to specify my exclude list.

So for example, under that "Peoplesoft" folder I have 3 folders called: export, import & PrintQueue. I want to exclude these folders from the tar command so that it will allow me to tar.

Thanks.
tar.JPG
0
matrix0511
Asked:
matrix0511
  • 4
1 Solution
 
woolmilkporcCommented:
Hi

-X expects the name of a file containing the names of the directories to be excluded, one by line.

The directories must appear in that file exactly as they would appear in the archive,
so in your case the content of the exclude list could look like:

PeopleSoft/PrintQueue
PepleSoft/export
PeopleSoft/edipd

Call this file e.g. /tmp/exclude.list and run

tar -X /tmp/exclude.list -cvf PeopleSoft.tar PeopleSoft


wmp


0
 
matrix0511Author Commented:
@woolmilkporc: so you are saying I need to first create an exclude list file and add those folders to it?

Im not very Unix savy, what's the best command to create this file and add those folders to the list?

Thanks!
0
 
woolmilkporcCommented:
Yes, you're right.

There are several ways to create a file under Unix, maybe the simplest:

cat >/tmp/catte <<EOF
PeopleSoft/PrintQueue
PepleSoft/export
PeopleSoft/import
EOF

Type the above line by line at the command prompt (terminate each line with <ENTER>), and you're done.

wmp
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
woolmilkporcCommented:
Sorry, "/tmp/catte" is nonsense.

Replace with "/tmp/exclude.list" !

0
 
xtermCommented:
It's erroring out because your user doesn't have permission to create the tar file in the folder you're running the command from

  $ tar -cvf PeopleSoft.tar PeopleSoft
  tar:  PeopleSoft.tar: Permission denied

Change your command to:

  $ tar -cvf /tmp/PeopleSoft.tar PeopleSoft

This will create your new tar file in /tmp.  Don't worry about the errors for the files you don't have permission to archive - the tar will still be created, but it just won't contain what you don't have access to.  You do not need to bother with the exclude list and X flag.
0
 
woolmilkporcCommented:
xterm, right you are.

Seems I solely looked at the lower part of what matrix0511 posted.

wmp

0

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now