tar backup of oe file type across disk

asjdo7

Registered
what is the syntax to use tar to backup indivual fiel types across the whole flesystem, ie: sepate backups of all pdf, doc, xls files into thier own tar ball
 
Alright, here you go:

> tar cpf mypdfs.tar *.pdf

That works, if you know where the files are... If you first have to find them, use the following:

> find / -name "*.pdf" -exec tar rpf mypdfs.tar {} ";"

Pay attention:
1. Change the '/' to the folder your searching in.
2. You need all the quotes, don't forget them.
 
Oh, I just forgot to tell you that in the second command, the "r" switch after the tar stands for (r like) append ;) So, the tarball has to exist before you run the command. A simple 'touch name.tar' won't do, neither a simple 'tar cf name.tar'. I forgot the neat solution, so my suggestion now would be: run the command twice, first with 'c' instead of the 'r' and the secondly the command as printed above... Or wrap a shell script around the procedure, whatever you want...
 
If you're using HFS+ as the filesystem, some of the files you're trying to backup may have resource forks, tar does not handle resource forks, so if the file has a resource fork, the file that tar backs up is useless.

Brian
 
That's true, tar isn't best choice for MacOSX as it was for Unix, originally. Hence, you are free to change my command to copy the specific file to a location from where you stuff it into an encrypted dmg via Disk Copy and burn it to a CD. That's how I usually backup my sensitive data.
 
You don't want to use the 'cp' command either as it also strips the resource fork. ditto is what you want to use if you're doing any copying of files that may have resource forks from the command line.

Brian
 
Back
Top