On Thu, 25 Jul 1996 16:13:40 -0400  Tom Nguyen wrote:

> Hi all,
> 
> Do you know if there is a way to backup only ACL under afs ?
> I'm thinking of backup afs files by using Unix tar. Later, if
> we need to restore files, we'll use tar and then restore ACL.
> 
> Tom N.
> 

Why not just use vos backupsys and butc?  I am sure that you could write
a couple of scripts to do this easily enough.  Here are two samples. I just
wrote.  They seem to be correct, but  I've not tested them in production --
so use with CAUTION -- check them first on unimportant volumes.  The backup
script is bourne shell and uses find.  The restore is in perl (because it
needs a little more parsing saavy.)   The beauty of it is that the saved
backup file is a simple ASCII file that you can read yourself.

NOTE:  These scripts do not attempt to create groups and/or users if they
don't exist.  And they do no serious error checking.  And they can get caught
in an infinite loop if you have circular mounts in AFS space.  (E.g. vol
A is mounted in vol B, and vol B is mounted in vol A.)  I consider these
scripts informational only, and assume no responsibility for however you
decide to use them!

        -- Garrett D'Amore
           UNIX System Administration Team
           QUALCOMM Incorporated
           [EMAIL PROTECTED]

#!/bin/sh

# backup_acls v0.0
#
# by Garrett D'Amore
# 7/25/96
#
# THIS IS UNSUPPORTED SOFTWARE -- USE IT AT YOUR OWN RISK!!!  THE
# USER AGREES TO HOLD THE AUTHOR(S) and QUALCOMM INCORPORATED HARMLESS,
# AND INDEMNIFY THEM FROM ANY CLAIM OF LOSS OR DAMAGE RESULTING FROM
# THE USE OF OR INABILITY TO USE THIS SOFTWARE -- EVEN IF SUCH LOSS
# RESULTS FROM GROSS NEGLIGENCE ON THE PART OF THE AUTHOR(S).
#

#
# Caveat: You must provide the *REAL* name for the directory, not a symbolic
# link!
#
aclsfile=$1
dir=$2
fs="/usr/afsws/bin/fs"

if [ -z "$dir" ]; then 
        echo "Usage: $0 <ACLfile> <dirname>";
        exit 1;
fi

echo "Saving ACLs from $dir to $aclsfile..."
cat /dev/null > $aclsfile
find $dir -type d -exec $fs la {} \; >> $aclsfile
#!/usr/bin/perl

# restore_acls v0.0
#
# by Garrett D'Amore
# 7/25/96
#
# THIS IS UNSUPPORTED SOFTWARE -- USE IT AT YOUR OWN RISK!!!  THE
# USER AGREES TO HOLD THE AUTHOR(S) and QUALCOMM INCORPORATED HARMLESS,
# AND INDEMNIFY THEM FROM ANY CLAIM OF LOSS OR DAMAGE RESULTING FROM
# THE USE OF OR INABILITY TO USE THIS SOFTWARE -- EVEN IF SUCH LOSS
# RESULTS FROM GROSS NEGLIGENCE ON THE PART OF THE AUTHOR(S).
#

$aclsfile=$ARGV[0];
shift(@ARGV);

$fs = "/usr/afsws/bin/fs";

if (!defined $aclsfile) {
        print "Usage: $0 <ACLfile>\n";
        exit 1;
}

print "Reading ACLs from $aclsfile...\n";

open(ACLS, "$aclsfile") || die;

while ($line = <ACLS>) {
        next if $line =~ /Normal rights/;       # skip bogus rights line
        if ($line =~ /Invalid argument/) {
                print "Hmmm... it appears this directory was not in AFS\n";
                next;
        }
        if ($line =~ /Access list for (\S+)/) {
                $dir = $1;
                print "Restoring acls for directory $dir...";
                next;
        }
        if (!defined $dir) {
                print "Hmmm... I don't know what directory to use!\n";
        }
        if ($line =~ /^\s+(\S+)\s+(\S+)/)
        {
                $group = $1;
                $acls = $2;
                system("$fs sa $dir $group $acls");
                next;
        }
        print "Uh oh!  $aclsfile doesn't look like an ACLfile to me!\n";
        exit 1;
}
close(ACLS);

Reply via email to