From owner-freebsd-questions Fri Jan 4 9:15: 2 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail.polaris.ca (pris.polaris.ca [199.247.156.218]) by hub.freebsd.org (Postfix) with SMTP id A3AEB37B405 for ; Fri, 4 Jan 2002 09:14:49 -0800 (PST) Received: (qmail 2449 invoked by uid 85); 4 Jan 2002 17:10:35 -0000 Received: from unknown (HELO tornado) (216.126.123.139) by 0 with SMTP; 4 Jan 2002 17:10:33 -0000 From: "Seamus.Venasse" To: , "'Scott Gerhardt'" , "'FreeBSD'" Subject: RE: Backup using TAR Date: Fri, 4 Jan 2002 09:14:42 -0800 Message-ID: <004e01c19543$4d000940$8b7b7ed8@tornado> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <3.0.5.32.20020104073128.01946370@mail.sage-american.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal X-Virus-Scanned: by AMaViS perl-11 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > -----Original Message----- > From: owner-freebsd-questions@FreeBSD.ORG > [mailto:owner-freebsd-questions@FreeBSD.ORG] On Behalf Of > jacks@sage-american.com > Sent: January 4, 2002 5:31 AM > To: Seamus.Venasse; 'Scott Gerhardt'; 'FreeBSD' > Subject: RE: Backup using TAR > > > I thought the tar "-p" option maintained the "permissions" (ownership) > ************************************************************* > -p > --same-permissions > --preserve-permissions Extract all protection information. > --preserve Has the effect of -p -s. > ************************************************************* Oh, it will preserve the permissions, but the permissions are only useful if you already have the user/group defined. For example, if I have a directory layout as: # ls -l -rw-r--r-- 1 svenasse svenasse 0 Jan 4 08:55 file1 -rw-r--r-- 1 mysql mysql 0 Jan 4 08:55 file2 -rw-r--r-- 1 svenasse svenasse 0 Jan 4 08:55 file3 -rw-r--r-- 1 www cvs 0 Jan 4 08:55 file4 -rw-r--r-- 1 www cvs 0 Jan 4 08:55 file5 -rw-r--r-- 1 mysql mysql 0 Jan 4 08:55 file6 -rw-r--r-- 1 mysql mysql 0 Jan 4 08:55 file7 And if I backup using the only preserve option in tar 1.11.2: # tar -cvvzpf backup.tgz file* -rw-r--r-- svenasse/svenasse 0 Jan 4 08:55 2002 file1 -rw-r--r-- mysql/mysql 0 Jan 4 08:55 2002 file2 -rw-r--r-- svenasse/svenasse 0 Jan 4 08:55 2002 file3 -rw-r--r-- www/cvs 0 Jan 4 08:55 2002 file4 -rw-r--r-- www/cvs 0 Jan 4 08:55 2002 file5 -rw-r--r-- mysql/mysql 0 Jan 4 08:55 2002 file6 -rw-r--r-- mysql/mysql 0 Jan 4 08:55 2002 file7 And now restore these files which may or may not have these accounts defined yet: # tar -xvvzf backup.tgz -rw-r--r-- svenasse/svenasse 0 Jan 4 08:55 2002 file1 -rw-r--r-- mysql/mysql 0 Jan 4 08:55 2002 file2 -rw-r--r-- svenasse/svenasse 0 Jan 4 08:55 2002 file3 -rw-r--r-- www/cvs 0 Jan 4 08:55 2002 file4 -rw-r--r-- www/cvs 0 Jan 4 08:55 2002 file5 -rw-r--r-- mysql/mysql 0 Jan 4 08:55 2002 file6 -rw-r--r-- mysql/mysql 0 Jan 4 08:55 2002 file7 # ls -l -rw-r--r-- 1 root wheel 240 Jan 4 09:01 backup.tgz -rw-r--r-- 1 svenasse svenasse 0 Jan 4 08:55 file1 -rw-r--r-- 1 root wheel 0 Jan 4 08:55 file2 -rw-r--r-- 1 svenasse svenasse 0 Jan 4 08:55 file3 -rw-r--r-- 1 root wheel 0 Jan 4 08:55 file4 -rw-r--r-- 1 root wheel 0 Jan 4 08:55 file5 -rw-r--r-- 1 root wheel 0 Jan 4 08:55 file6 -rw-r--r-- 1 root wheel 0 Jan 4 08:55 file7 Notice that, because mysql:mysql, www:cvs have not been defined yet, they extract as the user who is doing the extracting, and in this case, root:wheel. The whole thing done again using gnutar: # gtar --numeric-owner -cvvzf backup2.tgz file* -rw-r--r-- 1001/1001 0 2002-01-04 08:55:35 file1 -rw-r--r-- 88/88 0 2002-01-04 08:55:37 file2 -rw-r--r-- 1001/1001 0 2002-01-04 08:55:38 file3 -rw-r--r-- 80/1002 0 2002-01-04 08:55:39 file4 -rw-r--r-- 80/1002 0 2002-01-04 08:55:40 file5 -rw-r--r-- 88/88 0 2002-01-04 08:55:40 file6 -rw-r--r-- 88/88 0 2002-01-04 08:55:41 file7 # gtar --preserve-permissions --same-owner --numeric-owner -xvvzf backup2.tgz -rw-r--r-- 1001/1001 0 2002-01-04 08:55:35 file1 -rw-r--r-- 88/88 0 2002-01-04 08:55:37 file2 -rw-r--r-- 1001/1001 0 2002-01-04 08:55:38 file3 -rw-r--r-- 80/1002 0 2002-01-04 08:55:39 file4 -rw-r--r-- 80/1002 0 2002-01-04 08:55:40 file5 -rw-r--r-- 88/88 0 2002-01-04 08:55:40 file6 -rw-r--r-- 88/88 0 2002-01-04 08:55:41 file7 # ls -l -rw-r--r-- 1 root wheel 201 Jan 4 09:07 backup2.tgz -rw-r--r-- 1 svenasse svenasse 0 Jan 4 08:55 file1 -rw-r--r-- 1 88 88 0 Jan 4 08:55 file2 -rw-r--r-- 1 svenasse svenasse 0 Jan 4 08:55 file3 -rw-r--r-- 1 80 1002 0 Jan 4 08:55 file4 -rw-r--r-- 1 80 1002 0 Jan 4 08:55 file5 -rw-r--r-- 1 88 88 0 Jan 4 08:55 file6 -rw-r--r-- 1 88 88 0 Jan 4 08:55 file7 Now, I don't have uid/gid 88/88, 80/1002 defined yet, but the when the passwd file does finally extract from the backup, these permissions will be back as good. The method I showed won't work too well moving data from one system to another as the passwd/group files may be different, and not yielding the expected results. However, if the intention is to backup a system for restore later (ie: disaster recovery), then the method I showed is better suited for the task. Sorry for the long email. :) Seamus To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message