From owner-freebsd-questions@FreeBSD.ORG Sat Oct 25 00:54:00 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BA5F116A4B3 for ; Sat, 25 Oct 2003 00:54:00 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id F20ED43FCB for ; Sat, 25 Oct 2003 00:53:58 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h9P7rNDK066277 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 25 Oct 2003 08:53:52 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id h9P7rMoH066276; Sat, 25 Oct 2003 08:53:22 +0100 (BST) (envelope-from matthew) Date: Sat, 25 Oct 2003 08:53:22 +0100 From: Matthew Seaman To: Scott Gerhardt Message-ID: <20031025075322.GA65979@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Scott Gerhardt , 479001601@mail.ru, FreeBSD , Calvin Gordon References: <200310250833.17091.479001601@mail.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on happy-idiot-talk.infracaninophile.co.uk cc: Calvin Gordon cc: 479001601@mail.ru cc: FreeBSD Subject: Re: Help: tar & find X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Oct 2003 07:54:00 -0000 --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--