Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Oct 2003 08:53:22 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Scott Gerhardt <scott@g-it.ca>
Cc:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: Help: tar & find
Message-ID:  <20031025075322.GA65979@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <EC1E2E7A-06A8-11D8-B94B-000393801C60@g-it.ca>
References:  <200310250833.17091.479001601@mail.ru> <EC1E2E7A-06A8-11D8-B94B-000393801C60@g-it.ca>

next in thread | previous in thread | raw e-mail | index | archive | help

--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Oct 24, 2003 at 11:05:59PM -0600, Scott Gerhardt wrote:
> On Friday, October 24, 2003, at 10:33  PM, CBuH. wrote:
> >On Thursday 23 October 2003 15:34, Matthew Seaman wrote:
> >>On Wed, Oct 22, 2003 at 10:43:50PM -0600, Scott Gerhardt wrote:

> >>The problem is that you have file/directory names like 'ROOF LAYOUTS'
> >>which contain spaces and possibly other filenames containing
> >>characters with syntactic significance to the shell.
> >>
> >>Try:
> >>
> >>    find $FILES_DIR -xdev -type f -iname "*.bak -print0 | \
> >>        xargs -0 tar --remove-files -cvzpf $TAR_DIR/bak_files_`date
> >>+%F`.tar.gz

> >It'll have some _bad_ features:
> >If ``find'' will found to many files (default number of arguments to=20
> >be passed
> >by xargs to the ``utility'' (the tar command) is 5000, the default=20
> >size of
> >the command line is MAX_ARG (2048 bytes) //from man xargs), then xargs=
=20
> >will
> >run the ``utility'' twice, or more times,... consider it will be a=20
> >very small
> >differenses in time, you'll get that the last tar invocation 'll=20
> >replace your
> >archievs with that time stamp.

Yes, I noted that in my other message in this thread.  However, all
previously discussed variations (in this thread) on this command have
the same problem.

On FreeBSD the maximum possible argument list is long enough for most
purposes.  Unless the OP is going to be dealing with a great number of
files to back up then the commands as stated will work fine.

> 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.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--EeQfGwPcQSOJBaQU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/mivydtESqEQa7a0RAklpAJ9dlgM87k0jBnkNOrN5xnlaAFAwEQCePdA7
utKQavvciFTVJjRnglJIxBo=
=q7J6
-----END PGP SIGNATURE-----

--EeQfGwPcQSOJBaQU--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031025075322.GA65979>