Solved

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

Posted on 2004-10-13
7
323 Views
Last Modified: 2013-12-27
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
0
Comment
Question by:truelove258
  • 3
7 Comments
 
LVL 34

Accepted Solution

by:
PsiCop earned 500 total points
Comment Utility
"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?"

I don't think so. I think that password prompt is intrinsic to mode S. What you MAY be able to do is have your script call a tool like expect and complete login that way.

As an alternative, do you absolutely need Run Level S? How about Run Level 1?

Or, for that matter, just have your script call the shutdown scripts of the various running processes (Apache, Oracle, etc.), wait a bit, run the backup, and then call the startup scripts. That's what happens as you go from Run Level 3 to Run Level S - a series of scripts are called. Like I asked, does it ABSOLUTELY have to be Run Level S?
0
 

Author Comment

by:truelove258
Comment Utility
Yes, but how do I identify all the shutdown scripts and all of the startup scripts?
0
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
To get a crash course in how Run Levels and scripts interact in Solaris, see this PAQ --> http://www.experts-exchange.com/Q_21146972.html
0
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
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.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> ..  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).
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now