Date: Fri, 4 Jan 2002 09:14:42 -0800 From: "Seamus.Venasse" <Seamus.Venasse@polaris.ca> To: <jacks@sage-american.com>, "'Scott Gerhardt'" <scott@gerhardt-it.com>, "'FreeBSD'" <freebsd-questions@FreeBSD.ORG> Subject: RE: Backup using TAR Message-ID: <004e01c19543$4d000940$8b7b7ed8@tornado> In-Reply-To: <3.0.5.32.20020104073128.01946370@mail.sage-american.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> -----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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?004e01c19543$4d000940$8b7b7ed8>