tar question
What is the correct usage of the -X (exclude files from a backup) qualifier with the tar command? I would like to tar a directory that contains several subdirectories. There are many files I would like to exclude from several subdirectories in the backup. They are common in the fact that they have a common extension name.
tar -cvf mozilla .tar /home/user/.mozilla/user/jcx21zrd.slt/Mail would include all the files in /Mail and its subdirectories, right? How do I qaulifiy the tar command to exclude *.msf files in several different subdiretories in the backup? Thanks. |
find /home/user/.mozilla/user/jcx21zrd.slt/ -iname "*.msf" > ~/exclusion.txt
tar -X ~/exclusion.txt -cvf mozilla .tar /home/user/.mozilla/user/jcx21zrd.slt/Mail Cheers, Tink |
If I understand the man page correctly, the ( -X ) reads the file names from a list where ( file ) is the name of that list. That's not the way I do it.....
For example, to not tar any files with the html extension in my home directory and save that tar file to the /mnt directory, I would cd to the home directory and use this command..... tar --exclude="*.html" -cvzf /mnt/test.tar.gz . If you don't want to use the ( . ) to indicate ( present directory ) you can type out the path like this..... tar --exclude="*.html" -cvzf /mnt/test.tar.gz /home/* I think the tar --help explains that somewhat better than man tar :) |
Thanks to all. I ended up using the tar --exclude"" format as it was quicker.
Once again, though, a kind soul has shown me the power of the "find" command. Thanks very much! |
All times are GMT -5. The time now is 12:04 PM. |