From owner-freebsd-questions@FreeBSD.ORG Mon Aug 10 17:09:23 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF9B0106564A for ; Mon, 10 Aug 2009 17:09:23 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr3.xs4all.nl (smtp-vbr3.xs4all.nl [194.109.24.23]) by mx1.freebsd.org (Postfix) with ESMTP id 83BAD8FC21 for ; Mon, 10 Aug 2009 17:09:23 +0000 (UTC) Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr3.xs4all.nl (8.13.8/8.13.8) with ESMTP id n7AH9LsM060075; Mon, 10 Aug 2009 19:09:21 +0200 (CEST) (envelope-from rsmith@xs4all.nl) Received: by slackbox.xs4all.nl (Postfix, from userid 1001) id 3EC99BA8A; Mon, 10 Aug 2009 19:09:21 +0200 (CEST) Date: Mon, 10 Aug 2009 19:09:21 +0200 From: Roland Smith To: Jay Hall Message-ID: <20090810170921.GC49364@slackbox.xs4all.nl> References: <6206A242-7226-48E3-8D09-A1D3A651F2A8@socket.net> <20090810162528.GA49364@slackbox.xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="zCKi3GIZzVBPywwA" Content-Disposition: inline In-Reply-To: <20090810162528.GA49364@slackbox.xs4all.nl> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: freebsd-questions@freebsd.org Subject: Re: Backup Size 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: Mon, 10 Aug 2009 17:09:24 -0000 --zCKi3GIZzVBPywwA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 10, 2009 at 06:25:28PM +0200, Roland Smith wrote: > On Mon, Aug 10, 2009 at 10:21:58AM -0500, Jay Hall wrote: > > I am sure there is an easy explanation for this, but I cannot find it. > >=20 > > I am backing up my /etc directory using the following command. > >=20 > > tar -cvf - /etc | dd of=3D/dev/nsa1 obs=3D10240 >=20 > Why are you using dd? Tar was originally built to write to tape: >=20 > tar -cvf /dev/nsa1 /etc >=20 > > When the command completes, I receive the following message. > >=20 > > 3080+0 records in > > 154+0 records out > > 1576960 bytes transferred in 0.179921 secs (8764740 bytes/sec) > >=20 > > What concerns me is when running du -h /etc, the size of the folder is = =20 > > reported as 1.7M. >=20 > du rounds sizes up to the filesystem block size, which is 512 bytes by > default. So you'll bound to see differences. And see below. Oops, scratch that. Brain fart. du -h uses kilo-, mega- etc. bytes according to du(1). =20 > > Is the number of bytes written to the tape less than the reported size = =20 > > of the directory because of the way the files are written to the =20 > > tape? If so, how can the amount of space used be calculated? > =20 > The fact that you are using tar also plays a part. Tar has some overhead = to > store information about the files it contains. >=20 > If you want to know the total size of all files: >=20 > find /etc -type f -ls | awk \ > 'BEGIN {t=3D0; c=3D0}; END {print t " bytes in " c " files"}; {t=3Dt+$7; = c++}' >=20 > This returns '1320254 bytes in 362 files' in my case, while the tar/dd co= mbo > returns 1617920 bytes. The difference is the overhead for tar. >=20 > If you really want to check if tar does the right thing, restore the back= up to > a different place (e.g. /tmp/etc) and check with diff: >=20 > # rewind your tape to the correct position (not shown) > cd /tmp; tar xvf /dev/nsa1 > diff -ru /etc /tmp/etc >=20 > The diff command should give no output. >=20 > Roland --=20 R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --zCKi3GIZzVBPywwA Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (FreeBSD) iEUEARECAAYFAkqAVEEACgkQEnfvsMMhpyV6wwCYmbSzNlbREO5hzeM6/16iqcMm sACdG0sEMw00b5nAmxb3kOQuBnpaFNk= =Hp2f -----END PGP SIGNATURE----- --zCKi3GIZzVBPywwA--