Help: tar & find
Lowell Gilbert
freebsd-questions-local at be-well.ilk.org
Sat Oct 25 07:57:06 PDT 2003
> > Thanks for the response, but what would be a better solution?
>
> There are several possibilities, all of which equate to passing the
> list of files to backup to the tar command (or equivalent) via stdin
> rather than the command line. Perhaps the simplest is to use the '-I'
> or '-T' flag to tar(1):
>
> find $FILES_DIR -xdev -type f -iname '*.bak' -print0 | \
> tar --remove-files --null -T - \
> -cvzpf $TAR_DIR/bak_files_`date +%F`.tar.gz
>
> Other possibilities would include using cpio(1), which can be
> persuaded to emit tar format archives, or to build a perl backup
> script based around the File::Find and Archive::Tar modules.
Or passing the date in an environment variable.
I think something like
datestamp=`date +%F`
find $FILES_DIR -xdev -type f -iname '*.bak' -print0 | \
tar --remove-files --null -T - \
-cvzpf $TAR_DIR/bak_files_${datestamp}.tar.gz
should work.
More information about the freebsd-questions
mailing list