From owner-freebsd-questions@FreeBSD.ORG Fri Jul 8 04:33:24 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 1972716A41C for ; Fri, 8 Jul 2005 04:33:24 +0000 (GMT) (envelope-from matt@gsicomp.on.ca) Received: from skippyii.compar.com (mail2.compar.com [216.208.38.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id DC1D643D48 for ; Fri, 8 Jul 2005 04:33:21 +0000 (GMT) (envelope-from matt@gsicomp.on.ca) Received: from hermes (CPE00062566c7bb-CM000039c69a66.cpe.net.cable.rogers.com [70.28.254.189]) by skippyii.compar.com (8.13.1/8.13.1) with ESMTP id j684jBYs079129; Fri, 8 Jul 2005 00:45:13 -0400 (EDT) (envelope-from matt@gsicomp.on.ca) Message-ID: <001101c58376$3ada93f0$1200a8c0@gsicomp.on.ca> From: "Matt Emmerton" To: "Drew Tomlinson" References: <42CDF112.5070209@mykitchentable.net> <004701c5836e$7e3aa160$1200a8c0@gsicomp.on.ca> <42CDFA88.5000803@mykitchentable.net> Date: Fri, 8 Jul 2005 00:33:41 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Cc: FreeBSD Questions Subject: Re: tar Syntax Help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2005 04:33:24 -0000 > On 7/7/2005 8:38 PM Matt Emmerton wrote: > > > >>I'm trying to copy an entire file system while using an exclude file to > >>avoid copying things such as /dev, /proc, etc. I've read the man page > >>and found the -X or --exclude-from tar option. I've create a file > >>called /exclude.list. It contains lines such as: > >> > >>/exclude.list > >>/dev > >>/proc > >> > >>But I can't figure out how to form the correct command line. I > >>basically want to do this: > >> > >>tar -cvf - --exclude-from /exclude.list -C / . | tar xpf - -C . > >> > >>I've search the web and found examples that look similar to the above > >>but this does not work for me. tar attempts to copy /dev and I get all > >>the associated errors. I've tried other placements of either "-X", "X", > >>and "--exclude from" on the command line various things happen from it > >>just being ignored to tar thinking I want to create and archive named > >>"-X", etc., to tar trying to add a file named "-X", etc. to the current > >>archive. I'm at a loss. > >> > >>I'm using 4.11 and trying to make a good backup before upgrading to > >>5.4. Can anyone tell me the secret incantation to make this work? > >> > >> > > > >-X only works with specific files, not entire directories. You will need to > >list every file in /dev or /proc that you want to exclude, which is somewhat > >painful. > > > >The backup strategy that I've used on production systems is to back up each > >directory in a separate tar file. Not only does this work quicker (since > >you can fire off multiple tar sessions in parallel), but you can avoid > >"special" directories like /dev and /proc, temporary mount points such as > >/cdrom and /mnt, and other directories that don't need to backed up, such as > >/tmp. It's also quite handy when you've got large volumes of data (such as > >in /home) and the complete system image won't fit on a single tape. > > > >The general notion of my script is the following: > > > >#!/bin/sh > >for i in bin boot etc home modules root sbin usr var > >do > > tar cvzf /backups/$i.`date +%Y%m%d`.tar.gz $i & > >done > >wait > >echo "Backups completed!" > > > Thanks for your reply. I can do it this way and will for the sake of > speed. However this post suggests that one can use wildcards. > > http://lists.freebsd.org/pipermail/freebsd-questions/2004-July/052207.html > > Have you ever tried that? I did but was not successful. I just tried this out (on 5.4-REL) and the wildcards appear to work fine. If you specify wildcards on the command line (ie, with --exclude or -X), you must quote them to prevent premature expansion. -- Matt