- 论坛徽章:
- 0
|
我也来分享一个备份的脚本.
#!/sbin/sh
#
# Documentation at end of script
#
#
# Edit these values for your drive
#
####### EDIT THESE VALUES #######
SOURCE_DISK='c0t0d0'
DEST_DISK='c0t1d0'
DATA_SLICES='s0 s3'
SWAP_SLICES='s1'
####### EDIT THESE VALUES #######
for slice in $SWAP_SLICES; do
echo newfs on ${DEST_DISK}${slice}
/usr/sbin/newfs ${DEST_DISK}${slice}
done
for slice in $DATA_SLICES; do
echo newfs on ${DEST_DISK}${slice}
/usr/sbin/newfs ${DEST_DISK}${slice}
done
for slice in $DATA_SLICES; do
echo copying ${SOURCE_DISK}${slice} ${DEST_DISK}${slice}
/usr/sbin/mount /dev/dsk/${DEST_DISK}${slice} /mnt
mount
/usr/sbin/ufsdump 0f - /dev/rdsk/${SOURCE_DISK}${slice} \ | (cd /mnt;/usr/sbin/ufsrestore xf -)
/usr/sbin/umount /mnt
done
for slice in $DATA_SLICES; do
echo installboot on ${DEST_DISK}${slice}
/usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/${DEST_DISK}${slice}
done
exit
############################################################################
# Example partition table:
# Total disk cylinders available: 39533 + 2 (reserved cylinders)
#
# Part Tag Flag Cylinders Size Blocks
# 0 root wm 0 - 10158 4.88GB (10159/0/0) 10240272
# 1 swap wu 10159 - 10679 256.43MB (521/0/0) 525168
# 2 backup wm 0 - 39532 19.00GB (39533/0/0) 39849264
# 3 unassigned wm 10680 - 39532 13.87GB (28853/0/0) 29083824
# 4 unassigned wm 0 0 (0/0/0) 0
# 5 unassigned wm 0 0 (0/0/0) 0
# 6 unassigned wm 0 0 (0/0/0) 0
# 7 unassigned wm 0 0 (0/0/0) 0
############################################################################
#
# There are four steps to this process.
#
# 1) View the source drive to get slice information.
# 2) Format the destination drive with similar slices.
# 3) Edit this script between the lines that say:
# ####### EDIT THESE VALUES #######
# 4) Run this script.
#
#
#
# Step 1.
#
# Run 'format' and select the source disk.
#
# You should see something like this:
#
# # format
# Searching for disks...done
#
#
# AVAILABLE DISK SELECTIONS:
# 0. c0t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> gateway
# /pci@1f,4000/scsi@3/sd@0,0
# 1. c0t1d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>
# /pci@1f,4000/scsi@3/sd@1,0
# Specify disk (enter its number):
#
#
# For example, disk 0 could be the SOURCE disk and disk1 could be the DESTINATION disk.
#
# Select 'partition' and then 'print' to get the information above.
#
#
# Step 2.
#
# While still in the 'format' utility select the destination disk.
# Select 'partition' and 'print' to get the slice information for it.
#
# If you do not see the destination drive then you must exit format
# and run some disk utilities to make it visible.
#
# To add the destination drive, run:
# drvconfig
# devlinks
# disks
#
# Run 'format' again to see if the new disk is 'AVAILABLE'.
#
# Select 'partition' and then 'change' each partition to get similar slices.
#
# DO NOT CHANGE SLICE 2.
#
# The flags for data slices will be 'wm' and for the swap slice will be 'wu'.
# Allow 2.5 to 5 GB for the root partition, 256 to 512 MB for the swap slice
# and the rest for the export slice.
#
# DO NOT CHANGE SLICE 2.
#
#
# Step 3.
#
# You must edit the script and enter the correct values:
#
# DO NOT COPY SLICE 2.
#
# SOURCE_DISK='c0t0d0'
# DEST_DISK='c0t1d0'
# DATA_SLICES='s0 s3'
# SWAP_SLICES='s1'
#
# If you get SOURCE_DISK and DEST_DISK reversed you will overwrite the wrong disk.
# BE CAREFULL!!!
#
# In the example above there are four slices with non-zero cylinder numbers: 0,1,2,3.
#
# COPY NAME Function
# ==== ======= ====================================================================
# yes Slice 0 is the 'root' partition - copy it.
# yes Slice 1 is the 'swap' partition - only make the new file system.
# NO Slice 2 is the 'backup' partition - this represents the whole drive - DO NOTHING WITH THIS SLICE.
# yes Slice 3 is the 'export' partition - copy it.
#
# The script has two slice lists; one for the swap slice and one for data slices.
# The slices you put in the SWAP_SLICES will get 'newfs' (usually only slice 1).
# The slices you put in the DATA_SLICES will get 'newfs' and a 'ufs pipe copy'.
#
# DO NOT COPY SLICE 2.
#
# Step 4.
#
# Run this script. Answer 'yes' when it runs the 'newfs' command. |
|