Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
336 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 2000 total points
ID: 12300724
"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
ID: 12302279
Yes, but how do I identify all the shutdown scripts and all of the startup scripts?
0
 
LVL 34

Expert Comment

by:PsiCop
ID: 12302319
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
ID: 12302358
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
ID: 12311843
> ..  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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

916 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