On Tuesday 11 Mar 2003 1:13 pm, Mike Rees wrote:
Hi
Any idea how I can selectively backup certain type of files using tar (or otherwise) For example, (don't shoot me for this) *.doc, *.xls, *.pub files.
I'm trying to backup users home directories which inevitably contain loads of cr4p making the size of the archive balloon.
This is the kind of thing I'm using currently. Obviously, repeated for each directory and filetype I want to backup.
tar -cvf backup /etc /usr/bin/find /export/home/ -name *.doc -newer /etc/last.backup -exec tar -rvf backup {} \;
The script is getting longer and longer as I add new filetypes.
Am I missing something obvious? Can I feed find or tar multiple arguments ie the file types?
All help much appreciated....it's doing my head in!!
How about something like: [gary@gary gary]$ cat dobackup #!/bin/bash (echo /etc echo {anything else you want} find /home -newer /etc/passwd|perl -nle 'print if (/\.doc$|\.xls$|\.pub$/);' )|tar zcvf backup.tgz -T - [gary@gary gary]$ This will include any specific files or directories you wish, plus the output of the find/perl grep line in the tar file, which will be created by a single call to 'tar'. To add more file types you simply include it in the if condition. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000