Link to home
Start Free TrialLog in
Avatar of truelove258
truelove258

asked on

How do I get single user mode (init s) to not prompt for the root password so I can run a batch program for disk to disk copy and tape backups

Hi. I run a primary to secondary disk copy script and a tape backup script from single user mode every friday night. It has to run in single user mode because the gui and oracle and apache and tomcat need to get backed up and if I run from multi-user mode, critical data is not backed up, due to files being in use by processes. I need to be able to run an "init s" and then after the script is complete, run an "init 3" or a "reboot" after a wait state to get the OS back to normal for the morning shift. My problem is, that even though I am logged in as root, "init s" prompts for the root password to get into maintenance mode. Is there a way get around this so I can run my script from a cron job? If not, can you provide me a script that stops all unecessary processes (i.e. oracle, tomcat, apache, etc.), copies the entire contenets of the primary disk to the sescondary disk (i.e. in the eveny of a failure, I can swap the two hard drives), backs up the whole system to tape (the primary hard drive and the StorEdge 3300 (mount points /, /var, a01, a02, a03, a04, a05)?  My existing script looks like this:

set -vx      

# Make sure the mount point is free                                  
umount /mnt          

trap 'exit 1' 1 2                  

echo "Backup of boot disk started on " `date`                                            

# Check the disk and clean it up.                                
fsck -y /dev/dsk/c1t1d0s0                        
# fsck -y /dev/dsk/c1t1d0s1                          
fsck -y /dev/dsk/c1t1d0s3                        
newfs /dev/dsk/c1t1d0s0 << EOD                              
y
EOD  
# newfs /dev/dsk/c1t1d0s1 << EOD                                
y
EOD  
newfs /dev/dsk/c1t1d0s3 << EOD                              
y
EOD  

# Copy the root / slice                      
mount /dev/dsk/c1t1d0s0 /mnt
ufsdump 0f  -  /dev/rdsk/c1t0d0s0  |  (cd /mnt;ufsrestore -rf -) > /dev/null
umount /mnt

# Don't need to copy swap slice
#umount /mnt
#mount /dev/dsk/c1t1d0s1 /mnt
#ufsdump 0f  -  /dev/rdsk/c1t0d0s1  |  (cd /mnt;ufsrestore -rf -) > /dev/null
#umount /mnt

# Copy the /var slice
mount /dev/dsk/c1t1d0s3 /mnt
ufsdump 0f  -  /dev/rdsk/c1t0d0s3  |  (cd /mnt;ufsrestore -rf -) > /dev/null
umount /mnt

# Create master boot block record on target
mount /dev/dsk/c1t1d0s0 /mnt
/usr/sbin/installboot /usr/platform/sun4u/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0
umount /mnt

echo "Backup of boot disk completed on " `date`

set +vx

fsck /dev/rdsk/c1t0d0s0 -y                          
echo The tape is now rewinding. It will then backup root                                                        
ufsdump 0ucf /dev/rmt/0c /                          

# The 0 options specifies full backup, the rmt/0 option after rmt                                                                
# tells it TO REWIND THE TAPE!!!Then it backs up root /                                                      



fsck /dev/rdsk/c1t0d0s3 -y                          
echo The tape is now going to backup /var                                        
                           
fsck /dev/rdsk/c1t0d0s0 -y                          
echo The tape is now rewinding. It will then backup root                                                        
ufsdump 0ucf /dev/rmt/0c                        

# The 0 options specifies full backup, the rmt/0 option after rmt                                                                
# tells it TO REWIND THE TAPE!!!Then it backs up root /                                                      



fsck /dev/rdsk/c1t0d0s3 -y                          
echo The tape is now going to backup /var                                        
ufsdump 0ucf /dev/rmt/0nc  /var                              

# The 0 options specifies full backup, the 0n option after rmt                                                              
# tells it NOT TO REWIND THE TAPE!! IT APPENDS THE DATA!!                                                        
# Then it backs up /var                      
# The -u option record dumps to /etc/dumpdates file                                                  
# The -c option specifies a cartridge tape                                          
# The -f options specifies the tape drive                                        



##### Backs up /a04                  
echo The tape is now going to backup /a04                                        
fsck /dev/rdsk/c2t0d1s0  -y                          
ufsdump 0ucf /dev/rmt/0nc /a04/                              


##### Backs up /u05; This mount point is the StorEdge 3310 RAID5                
echo The tape is now going to backup /a05
fsck /dev/rdsk/c2t0d2s0 -y
ufsdump 0ucf /dev/rmt/0nc /a05


####### Backus up /a01
echo The tape is now going to backup /a01
fsck /dev/rdsk/c2t0d0s5 -y
ufsdump 0ucf /dev/rmt/0nc /a01

####### Backups up /a02
echo The tape is now going to backup /a02
fsck /dev/rdsk/c2t0d0s7  -y
ufsdump 0ucf /dev/rmt/0nc /a02/


##### Backs up /a03
echo The tape is now going to backup /a03
fsck /dev/rdsk/c2t0d0s6 -y
ufsdump 0ucf /dev/rmt/0nc /a03

echo Backup is now complete
echo Check status of backup at /etc/dumpdates
ASKER CERTIFIED SOLUTION
Avatar of PsiCop
PsiCop
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of truelove258
truelove258

ASKER

Yes, but how do I identify all the shutdown scripts and all of the startup scripts?
To get a crash course in how Run Levels and scripts interact in Solaris, see this PAQ --> https://www.experts-exchange.com/questions/21146972/Deamons-Looking-for-which-script-or-what-files-starts-the-deamons.html
Generally speaking, to get from Run Level 3 to, say, Run Level 1, you should execute /etc/rc3.d/K* and /etc/rc2.d/K*, passing each script a parameter of "stop". Thus --> /etc/rc2.d/K91something stop

That's the brute-force way. A nicer way is to identify those specific daemons you need stopped, and execute just their unload scripts, and not every unload script in the /etc/rc?.d sub-dir structure.
> ..  how do I identify all the shutdown scripts ..
as stated in your initial question, you only do the "init s" 'cause of processes with exclusive file locks and/or unflushed data, like oracle.

Why not simply shutdown those processes. That should be enough for a backup. Solaris don't use processes which cannot be backed-up while running, or they have a special backup mode (like ldap).