tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY : Restoring quotas
@ 1997-02-24 15:19 Magali.Bernard
  0 siblings, 0 replies; only message in thread
From: Magali.Bernard @ 1997-02-24 15:19 UTC (permalink / raw)
  To: tru64-unix-managers


Original post :

> Next week we have to change our alpha server machine.
> 
> Users are to be transferred from the old machine to the new one, with
> their quotas on /home. How can we keep AdvFS quotas on the new server ?
> 
> It seems that vrestore does *not* restore the files quota.user and
> quota.group, and it would be a long work to recreate all quotas
> for 1000 users.

Thanks to:
"Richard L Jackson Jr" <rjackson@gmu.edu>
Alan Rollow - alan@nabeth.cxo.dec.com
Igor Natanzon <sysadmin@sba.miami.edu>
Tim Mark USG <tmark@zk3.dec.com>

I omitted to tell my OS is 3.2C
It seems the problem is fixed for versions 4.0 and later.

Igor Natanzon <sysadmin@sba.miami.edu> told me :
> Well..there is no way to easily restore quotas. I have written a program
> that can be used among other things, to back up quota info. The program
> would create a text file with quota information, then it can be read by
> the program in order to restore it.
> You would need to run this program and ask it to do quota backup. You can
> then copy the file it created into the new machine . You can then run the
> restore option. Program has many features, including ability to set quotas
> based on group memberships, and using files with lists of users...etc...

but I didn't ask him this tool because I already got one from
"Richard L Jackson Jr" <rjackson@portal.gmu.edu> (my need was only to
transfer the user quota, not the group quota). Here the message from
"Richard L Jackson Jr" <rjackson@portal.gmu.edu>, works fine for me:

> This is a known 'issue' with 3.2x vrestore.  I heard that it is fixed in
> 4.0x but I have not verified this information.  I too have the same problem
> since my user base 35,000 - 45,000.  So, I developed the following C
> program and script.  You will need to modify your vdump job to save a
> copy of vrepquota prior to the actual backup.  For example,
> 
> . cd FILESYSTEM
> . vrepquota FILESYSTEM > quota.report
> . chmod 640 quota.report
> . chown root.operator quota.report
> . vdump blah blah
> 
> The quota.report file is used to re-gen the quotas by fixvquota.ksh and
> fixvquota.c.
> 
> fixvquota.c --------------------------------------------------------------
> /**********************************************************************/
> /*                                                                    */
> /* NAME: fixvquota.c                                                  */
> /*                                                                    */
> /* PROGRAMMER: Richard Jackson                     DATE: 950328       */
> /*                                                                    */
> /* PURPOSE: Set the quota for a specified user on a specified         */
> /*          filesystem.  This routine's purpose is to compensate for  */
> /*          vdump/vrestore commands not restoring AdvFS user quotas.  */
> /*                                                                    */
> /* NOTES:                                                             */
> /*        To execute:                                                 */
> /*             1. fixvquota username softlimit hardlimit filesystem   */
> /*             for example,                                           */
> /*                ./fixvquota jblow 2000 2500 /var/spool/mail         */
> /*                                                                    */
> /*        To build under OSF/1 3.x:                                   */
> /*          1. cc -O -non_shared -om -o fixvquota fixvquota.c         */
> /*          2. strip fixvquota                                        */
> /*                                                                    */
> /*        Only root can successfully run this program.                */
> /*                                                                    */
> /*                                                                    */
> /* MODIFICATION HISTORY:                                              */
> /* DATE      MOD  NAME       DESCRIPTION                              */
> /*                                                                    */
> /* 950328    AAA  rjackson   initial version                          */
> /* 961205    AAB  rjackson   add Q_SYNC call to flush to disk         */
> /*                                                                    */
> /**********************************************************************/
> 
> #include <stdio.h>                              /* printf() */
> #include <pwd.h>                                /* getpwnam() */
> #include <stdlib.h>                             /* atoi(), exit() */
> #include <sys/types.h>
> #include <ufs/quota.h>                          /* quotactl() */
> #include <sys/mount.h>                          /* statfs() */
> #include <errno.h>                              /* perror() */
> #include <unistd.h>                             /* geteuid() */
> 
> main (int argc, char *argv[])
> {
>   struct dqblk   dqblk_st;              /* disk quota structure */
>   struct passwd *pw;                    /* passwd file entry structure */
>   u_int          softlimit;             /* quota soft limit */
>   u_int          hardlimit;             /* quota hard limit */
>   struct statfs  statfs_st;             /* mounted filesystem info */
>   uid_t          uid;                   /* user id */
> 
> /*
>  * make sure we have the required arguments
>  */
>   if (argc != 5)
>   {
>     fprintf(stderr, "Usage: fixvquota username softlimit hardlimit filesystem\n"
> );
>     exit(1);
>   }
> 
> /*
>  * this program requires root
>  */
>   if ( geteuid() != (uid_t) 0)
>   {
>     fprintf(stderr, "%s: you must be root\n", argv[0]);
>     exit(1);
>   }
> 
> /*
>  * does this user exist in the /etc/passwd file?
>  */
>   if ((pw = getpwnam(argv[1])) == (struct passwd *) NULL)
>   {
>     fprintf(stderr, "%s: can't find passwd entry for %s\n", argv[0], argv[1]);
>     exit(1);
>   }
> 
> /*
>  * check if quota's are valid for the specified filesystem
>  */
>   if (statfs(argv[4], &statfs_st, sizeof(struct statfs)))
>   {
>     fprintf(stderr, "%s: statfs() failed, errno=%d\n", argv[0], errno);
>     exit(1);
>   }
> 
> /*
>  * Filesystem should manage quotas or be AdvFS (i.e., AdvFS always
>  * manages quotas).  M_QUOTA appears to not be set for AdvFS.
>  */
>   if (!((statfs_st.f_flags & M_QUOTA) || (statfs_st.f_type == MOUNT_MSFS)))
>   {
>     fprintf(stderr, "%s: quota is not enabled for %s filesystem",
>          argv[0], argv[4]);
>     exit(1);
>   }
> 
> /*
>  * fetch current values
>  */
>   if (quotactl(argv[4], QCMD(Q_GETQUOTA, USRQUOTA), pw->pw_uid, &dqblk_st))
>   {
>     fprintf(stderr, "%s: quotactl() GETQUOTA failed, errno=%d\n",
>          argv[0], errno);
>     exit(1);
>   }
> 
>   softlimit = atoi(argv[2]);
>   hardlimit = atoi(argv[3]);
> 
> /*
>  * disk blocks (512 bytes each) times 2.  vquota reports number of 1024
>  * byte blocks.
>  */
>   dqblk_st.dqb_bsoftlimit = softlimit * 2;
>   dqblk_st.dqb_bhardlimit = hardlimit * 2;
> 
> /*
>  * set new quotas
>  */
>   if (quotactl(argv[4], QCMD(Q_SETQUOTA, USRQUOTA), pw->pw_uid, &dqblk_st))
>   {
>     fprintf(stderr, "%s: quotactl() SETQUOTA failed, errno=%d\n",
>          argv[0], errno);
>     exit(1);
>   }
> 
> /*
>  * update the on-disk copy of quota.  id and dqblk_st ignored.  See quotactl(1)
>  */
>   if (quotactl(argv[4], QCMD(Q_SYNC, USRQUOTA), pw->pw_uid, &dqblk_st))
>   {
>     fprintf(stderr, "%s: quotactl() SYNC failed, errno=%d\n", argv[0], errno);
>     exit(1);
>   }
> 
>   exit(0);
> 
> }
> --------------------------------------------------------------------------
> 
> fixvquota.ksh --------------------------------------------------------------
> #!/bin/ksh
> ########################################################################
> #                                                                      #
> # NAME: fixvquota.ksh                                                  #
> #                                                                      #
> # PROGRAMMER: rjackson                            DATE: 950328         #
> #                                                                      #
> # PURPOSE:  Set the quota, using fixvquota, for users specified in     #
> #           OSF/1 3.2a vrepquota report output.                        #
> #                                                                      #
> #   vrepquota output format:                                           #
> #                                                                      #
> #                        Block limits               File limits        #
> #User            used    soft    hard  grace    used  soft  hard  grace#
> #root      --     123       0       0             19     0     0       #
> #rjackson  --    1449    2000    2500            160     0     0       #
> #                                                                      #
> # NOTES:                                                               #
> #         to execute:                                                  #
> #             1. fixvquota.ksh /usr/u1 < vrepquota.out                 #
> #                                                                      #
> #         where /usr/u1 is the filesystem to rebuild user quotas.      #
> #                                                                      #
> # MODIFICATION HISTORY:                                                #
> # DATE      MOD  NAME       DESCRIPTION                                #
> #                                                                      #
> # 950328    AAA  rjackson   initial version                            #
> #                                                                      #
> ########################################################################
> #
> umask 027
> 
> AWK=/usr/bin/awk
> FIXVQUOTA=/usr/local/system/fixvquota
> 
> FILESYSTEM=$1
> 
> #
> # skip first two vrepquota headers.
> #
> read REC
> read REC
> 
> while read REC
> do
>   USER=`echo $REC|$AWK '{print $1}'`
>   SOFT=`echo $REC|$AWK '{print $4}'`
>   HARD=`echo $REC|$AWK '{print $5}'`
> 
>   $FIXVQUOTA $USER $SOFT $HARD $FILESYSTEM
> done                            # main while loop
> 
> exit 0
> --------------------------------------------------------------------------
> 
> -- 
> Regards,
> Richard Jackson                                George Mason University
> Computer Systems Senior Engineer               UCIS / ISO
>                                                Computer Systems Engineering

Thanks again.

-- 
_______________________________________________________________________
Magali BERNARD (magali@univ-st-etienne.fr)
CRITeR - 23 rue du Dr Paul Michelon - 42023 St-Etienne Cedex 2 - FRANCE
Tel: 04.77.48.50.62

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-02-24 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-02-24 15:19 SUMMARY : Restoring quotas Magali.Bernard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox