Performing File system Restore including incremental back up (solaris 10)

The ufsrestore command copies files to the disk, relative to the current
working directory, from backup tapes that were created by the ufsdump command.

The syntax for the ufsrestore command is:
ufsrestore option(s) argument(s) filesystem


The following procedure demonstrates how to use the ufsrestore command to restore the /export/home file system on the c0d1s7 slice.

1. Create the new file system structure.

# newfs /dev/rdsk/c0d1s7


2. Mount the file system to the /export/home directory, and change to that directory.

# mount /dev/dsk/c0d1s7 /export/home

# cd /export/home


3. Restore the entire /export/home file system from the backup tape.

# ufsrestore rf /dev/rmt/0


Note – Always restore a file system by starting with the Level 0 backup tape, continuing with the next-lower-level tape, and continuing through the highest-level tape.


4. Remove the restoresymtable file.

# rm restoresymtable

Remove the restoresymtable file when the restore is complete.


5. Unmount the new file system.

# cd /

# umount /export/home


6. Use the fsck command to check the restored file system.

# fsck /dev/rdsk/c0d1s7


7. Perform a full backup of the file system.

# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0d1s7

The ufsrestore command repositions the files and changes the inode allocation.


8. init 6



Using the ufsrestore Command to Restore a Critical File System

The following procedure demonstrates how to restore the /usr file system on Slice 6 of the boot disk.

1. Insert the Solaris 10 Software 1 CD-ROM or DVD, and boot from it with the     single-user mode option.

ok boot cdrom -s


2. Create the new file system structure.

# newfs /dev/rdsk/c0t0d0s6


3. Mount the file system to the mount point /a, and change to that directory.

# mount /dev/dsk/c0t0d0s6 /a

# cd /a


4. Restore the entire /usr file system from the backup tape.

# ufsrestore rf /dev/rmt/0


5. Remove the restoresymtable file.

# rm restoresymtable


6. Unmount the new file system.

# cd /
# umount /a


7. Use the fsck command to check the restored file system.

# fsck /dev/rdsk/c0t0d0s6


8. Perform a full backup of the file system.

# ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t0d0s6


9. Reboot the system.

# init 6



Invoking an Interactive Restore
The following procedure demonstrates how to use the ufsrestore i command to extract individual files from a backup tape.

1. Become the root user, and change to the temporary directory that you want     to receive the extracted files.

# cd /export/home/tmp


2. Perform the ufsrestore i command.

# ufsrestore ivf /dev/rmt/0


3. Display the contents of the directory structure on the backup tape.

ufsrestore > ls
.:
     2 *./      13 directory1 15 directory3 11 file2
     2 *../     14 directory2 10 file1      12 file3


4. Change to the target directory on the backup tape.

ufsrestore > cd directory1
ufsrestore > ls
./directory1:
  3904 ./           2 *../ 3905 file1 3906 file2 3907 file3


5. Add the files you want to restore to the extraction list.

ufsrestore > add file1 file2
Make node ./directory1

Files you want to restore are marked with an asterisk (*) for extraction.
If you extract a directory, all of the directory contents are marked for extraction.

In this example, two files are marked for extraction.
The ls command displays an asterisk in front of the selected file names, file1 and file2.

ufsrestore > ls
./directory1:
  3904 *./      2 *../ 3905 *file1 3906 *file2 3907 file3


6. To delete a file from the extraction list, use the delete command.

ufsrestore > delete file1

The ls command displays the file1 file without an asterisk.

ufsrestore > ls
./directory1:
  3904 *./      2 *../ 3905 file1 3906 *file2 3907 file3


7. To view the files and directories marked for extraction, use the marked
   command.

ufsrestore > marked
./directory1:
  3904 *./          2 *../ 3906 *file2


8. To restore the selected files from the backup tape, perform the command:

ufsrestore > extract

Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1

extract file ./directory1/file2
Add links
Set directory mode, owner, and times.
set owner/mode for ‘.’? [yn] n

Answering y sets ownership and permissions of the temporary directory to those of the mount point on the tape.


9. To exit the interactive restore after the files are extracted, perform the
   command:

ufsrestore> quit


10. Move the restored files to their original or permanent directory
    location, and delete the files from the temporary directory.

# mv /export/home/tmp/directory1/file2 /export/home

# rm -r /export/home/tmp/directory1


Note – You can use the help command in an interactive restore to display a list of available commands.



Performing an Incremental Restore
The following procedure demonstrates how to restore the /export/home file system from incremental tapes.


Note – This procedure makes use of the interactive restore to assist in showing the concept of incremental restores. You would typically use a command, such as ufsrestore rf, for restoring entire file systems.


1. View the contents of the /etc/dumpdates file for information about
   the /export/home file system.

# more /etc/dumpdates | grep c0t0d0s7

/dev/rdsk/c0t0d0s7       0 Wed Apr 07 09:55:34 2004
/dev/rdsk/c0t0d0s7       1 Web Apr 07 09:57:30 2004


2. Create the new file system structure for the /export/home file system.

# newfs /dev/rdsk/c0t0d0s7


3. Mount the file system and change to that directory.

# mount /dev/dsk/c0t0d0s7 /export/home

# cd /export/home


4. Insert the Level 0 backup tape.


5. Restore the /export/home file system from the backup tapes.

# ufsrestore rvf /dev/rmt/0


6. Load the next lower-level tape into the tape drive.

# ufsrestore rvf /dev/rmt/0



Alternative Steps


The following steps are an alternative to the previous Steps 5 and 6.

5. Restore the /export/home file system from the backup tapes. (This
   example uses an interactive, verbose restore to provide more detailed
   information.)

# ufsrestore ivf /dev/rmt/0

ufsrestore > ls

The system lists files from the last Level 0 backup.

ufsrestore > add *

ufsrestore > extract

Specify next volume #: 1

set owner/mode for ’.’? [yn] n

Directories already exist, set modes anyway? [yn] n

ufsrestore > q
#


6. The information in the /etc/dumpdates file shows an incremental
   backup that was taken after the Level 0 backup. Load the next tape
   and perform the incremental restore.

# ufsrestore ivf /dev/rmt/0

ufsrestore > ls

ufsrestore > add *

ufsrestore > extract

Specify next volume #: 1

set owner/mode for ’.’? [yn] n

ufsrestore > q

Performing File system Backup ( solaris 10 )


Strategies for Scheduled Backups


A full backup is a complete file system backup.

An incremental backup copies only files in the file system that have been added or modified since a previous lower-level backup.

Backups are often referred to as dumps.

Use dump level 0 to perform a full backup.

Use dump levels 1 through 9 to schedule incremental backups


# ufsdump 0S filesystem_name    ==> to determine the size of the file system
                    to be backed up

        or

# ufsdump 3S filesystem_name

S - size estimate


The /etc/dumpdates file records backups if the -u option is used with the ufsdump command.

# cat /etc/dumpdates


Backing Up an UNMOUNTED File System

/usr/sbin/ufsdump

The syntax for the ufsdump command is:

ufsdump option(s) argument(s) filesystem_name


Tape Back Ups
Perform the following steps to use the ufsdump command to start a tape backup:

1. Become the root user to change the system to single-user mode, and
   unmount the file systems.

# /usr/sbin/shutdown -y -g300 “System is being shutdown for backup”


2. Verify that the /export/home file system was unmounted with the
   shutdown command. If not, unmount it manually.


3. Check the integrity of the file system data with the fsck command.

# fsck /export/home


4. Perform a full (Level 0) backup of the /export/home file system.

# ufsdump 0uf /dev/rmt/0 /export/home


# ufsrestore tf /dev/rmt/0    ==> t - to list the table of contents of the                         backup media

# ufsrestore tvf /dev/rmt/0



Remote Backups to a Tape

To perform a backup on a remote tape device.

ufsdump options remotehost:tapedevice filesystem

To perform remote backups across the network, the system with the tape drive must have an entry in its /.rhosts file for every system that uses the tape drive.


The following example shows how to perform a full (Level 0) backup of the
/export/home file system on the host1 system, to the remote tape device on the host2 system.

# ufsdump 0uf host2:/dev/rmt/0 /export/home

User Creation and Remove commands in solaris 10

Creating User Accounts

To create a user account:

# useradd -u 100 -g other -d /export/home/newuser1 -m -s /bin/ksh -c
"Regular User Account" newuser1

# passwd newuser1


# /usr/sadm/bin/smuser add -- -n newuser2 -u 500 -g other -d
/export/home/newuser2 -c "Regular User Account 2" -s /bin/ksh -x
autohome=N

# passwd newuser2


Modifying User Accounts


To change the login name and home directory for newuser1 to usera.

# usermod -m -d /export/home/usera -l usera newuser1

To change the login name and home directory for newuser2 to userb.

# /usr/sadm/bin/smuser modify -- -n newuser2 -N userb -d /export/home/userb



Deleting User Accounts
# userdel usera        ==> to remove the user account

# userdel -r usera    ==> to remove both the users account & home directory


# /usr/sadm/bin/smuser delete -- -n userb    ==> the users home directory                             should be deleted manually


Creating a Group Entry
# groupadd -g 301 class1

# /usr/sadm/bin/smgroup add -- -n workgroup -g 123 -m usera


Modifying a Group Entry
# groupmod -g 400 class1    ==> to change group ID

To change group name
# /usr/sadm/bin/smgroup modify -- -n workgroup -N schoolgroup


Deleting a Group Entry
# groupdel class1

# /usr/sadm/bin/smgroup delete -- -n schoolgroup



# vi /etc/default/passwd    ==> to control the properties for all users’
                    passwords on the system:


# ls -l /usr/sadm/defadduser    ==> to display default values for useradd
                    command

# useradd -D

# cat /usr/sadm/defadduser

Package administration in solaris 10

Administering Packages

    pkgadd        Installs software packages to the system

    pkgrm        Removes a package from the system

    pkginfo        Displays software package information

    pkgchk        Checks package installation state

    pkgtrans    Translates packages from one format to another


# more /var/sadm/install/contents    ==> to list all installed software                             packages


# pkginfo | more    ==> to display information about installed software                     packages

# pkginfo -l | more    ==> to view additional information

# pkginfo -l SUNWman    ==> to view information of a specific package

# pkginfo | wc -l    ==> to find how many packages are currently installed


To view information about packages that are located on the DVD


# pkginfo -d /cdrom/cdrom0/s0/Solaris_10/Product | more

# pkginfo -d /cdrom/cdrom0/Solaris_10/Product | more



Checking a Package Installation
The pkgchk command checks to determine if a package has been installed on the system. If the pkgchk command does not display a message, it indicates the package was installed successfully and that no changes have been made
to any files or directories in the package.


# pkgchk SUNWladm    ==> to check the contents & attributes of a                     currently installed package

# pkgchk -v SUNWladm    ==> to list the files contained in a software package

# pkgchk -p /etc/shadow    ==> to find if the contents & attributes of a file                     have changed since it was installed with its                     software package

# pkgchk -l -p /usr/bin/showrev    ==> to list information about selected files                         that make up a package

# pkgchk -l -P showrev    ==> to find if a particular file is installed & to                     find the directory in which it is located

If -p option is used, the full path must be typed to get information about the file. If -P option is used, a partial path name can be used.



Adding a Software Package from DVD

Example: To transfer the SUNWvts software package from CD-ROM & install it

# cd /cdrom/cdrom0/Solaris_10/ExtraValue/CoBundled/SunVTS_6.0/Packages

# pkgadd -d . SUNWvts


Adding Packages by Using a Spool Directory

The pkgadd command, by default, looks in the /var/spool/pkg directory for any packages specified on the command line.

The default directory for packages that have been spooled, but not installed is /var/spool/pkg.


To copy a package from the Solaris DVD into the /var/spool/pkg directory

# pkgadd -d /cdrom/cdrom0/s0/Solaris_10/Product -s spool SUNWauda

The -s option with the keyword spool copies the package into the /var/spool/pkg directory by default.


# ls -al /var/spool/pkg        ==> to verify if the package exists in the                         spool directory

# pkgadd SUNWauda        ==> to add the package from the spool area

# pkgrm -s spool SUNWauda    ==> to remove a package from the spool area



To use an alternative spooling directory


# pkgadd -d /cdrom/cdrom0/s0/Solaris_10/Product -s /export/pkg SUNWauda

# pkgrm -s /export/pkg SUNWauda        ==> to remove a package from the
                        spool directory



Removing a Software Package


Caution – Be cautious of the dependency warnings you receive when removing a package. The system allows you to remove these packages even though they may be required by a different package.

# pkgrm SUNWauda



PACKAGE FORMATS
File system (or Directory) format: Multiple files and directories.

A package (SUNWrsc) in file system format:

# ls -ld SUNWrsc

# cd SUNWrsc
# ls -l


Data stream format: Single file.
A package in data stream format:

# ls -l SUNWrsc.pkg

# file SUNWrsc.pkg

# head SUNWrsc.pkg


Translating Package Formats

To translate a package from file system format in /var/tmp to data stream format

# pkgtrans /var/tmp /tmp/SUNWrsc.pkg SUNWrsc

First argument is the directory where file system format package is stored. Second argument is the package data stream file.
Third argument is the package to translate.

If no package name is given a list of all packages in the directory is displayed


# pkgadd -d /tmp/SUNWrsc.pkg all    ==> to install packages in a data
                        stream format


Example:

To create a data streamed package

# cd /cdrom/cdrom0/s0/Solaris*

# pkgtrans -s Product /var/tmp/stream.pkg SUNWzlib SUNWftpr SUNWftpu

# file /var/tmp/stream.pkg

# head -5 /var/tmp/stream.pkg

# pkgadd -d /var/tmp/stream.pkg

Performing Mount and unmount

To view which file systems are currently mounted

# mount
# more /etc/mnttab
# df -h           


Temporary mount

# mount /dev/dsk/c0d1s6 /directoryname


To mount a filesystem permanently


# vi /etc/vfstab

/dev/dsk/c0d1s6 /dev/rdsk/c0d1s6 /mountpoint    ufs 2   yes  -

:wq


Mount Options

syntax: mount -o option,option,... device_name mount_point

# mount -o ro,nosuid /dev/dsk/c0d1s6 /mountpoint
# mount -o noatime /dev/dsk/c0d1s6 /mountpoint
# mount -o nolargefiles /dev/dsk/c0d1s6 /mountpoint


# mountall     ==> to mount all file systems listed in /etc/vfstab file

# mountall -l     ==> to mount only local filesystems listed in /etc/vfstab file


Mounting Different Types of File Systems

# fstyp /dev/rdsk/c0d1s7     ==> to view a filesystem type

# mount -F hsfs -o ro /dev/dsk/c0d0s0 /cdrom    ==> to mount a CD-ROM


To mount a file system that resides on a diskette when the Volume Management (vold) services are stopped

# mkdir /pcfs
# mount -F pcfs /dev/diskette /pcfs


Unmounting File Systems


# umount /export/home        ==> unmount using directory mount point

# umount /dev/dsk/c0d1s7    ==> unmount using logicak disk device name

# umountall    ==> to unmount all filesystems listed in /etc/mnttab file

# umountall -l     ==> to unmount only local filesystems

The umountall unmounts all file systems specified in the vfstab file except
/ (root), /usr, /proc, /dev/fd, /var, /var/run, and /tmp.


Unmounting a Busy File System


# umount -f mountpoint    ==> to force unmount a filesystem


# fuser -cu mountpoint    ==> to list all processes accessing the filesystem

# fuser -ck mountpoint    ==> to kill all processes accessing the file system

# fuser -c mountpoint    ==> to verify if all processes are killed

# umount mountpoint


Restricting Access to Mounted Diskettes, CD-ROMs, or DVDs


# /etc/init.d/volmgt stop    ==> to stop Volume Management (vold) service

# /etc/init.d/volmgt start    ==> to start Volume Management service

Managing solaris os file system

Creating a New ufs File System

# newfs /dev/rdsk/c0d1s6    ==> to create a new filesystem

# fstyp -v /dev/rdsk/c0d1s6 | head     ==> to view minfree value

# newfs -m 2 /dev/dsk/c0d1s6    ==> to set minfree value for a new filesystem

# tunefs -m 1 /dev/rdsk/c0d1s6    ==> to change minfree value on an existing                         file system


Checking the File System


Never run the fsck command on a mounted file system.

# fsck /dev/rdsk/c0d1s6        ==> to check an unmounted filesystem

# fsck /export/home        ==> to check using the mount point directory


# fsck -o f,p /dev/rdsk/c0d1s6

    f - forces a file system check
    p - checks and fixes the file system noninteractively (preen). The
        program exits immediately if a problem requiring intervention is             found.


# fsck -o b=32 /dev/rdsk/c0d1s6        ==> to use a backup superblock

# newfs -N /dev/rdsk/c0d1s6    ==> to list the locations of all the                         alternative backup superblocks

    N - to view the file system parameters without actually creating the             file system


# fsck -o b=518432 /dev/rdsk/c0d1s6    ==> to use an alternative superblock                             number


# newfs -N -T /dev/rdsk/c1t3d0s7

    T - allows the file system to be a multi-Terabyte file system


Monitoring File System Use


To display the capacity of file systems

# df -k                ==> disk allocation in Kbytes

# df -h             ==> human readable format

# df -k /dev/dsk/c0d1s6        ==> to view available space on a device


To display disk usage

# cd /opt
# du -k            ==> disk usage in kilobytes

# du -h /opt | more    ==> human readable format

# du -ak /opt        ==> disk usage including files

# du -sk /opt        ==> summary of disk usage


# quot -af    ==> to display disk space used by users on all mounted file                 systems in kb

    a - reports on all mounted file systems
    f - number of files


# quot -f /dev/dsk/c0d1s6    ==> to display disk space used by users for                         a specific file system

Managing Local disk devices (solaris 10)

To display a physical device name

# ls -l /dev/dsk/c0d1s0

# ls -l /dev/rdsk/c0d1s0


Instance names are abbreviated names assigned by the kernel for each device on the system. An instance name is a shortened name for the physical device name.

# cat /etc/path_to_inst        ==> to view the physical name and instance                         name of devices


# prtconf    ==> to display the system’s configuration information


# format     ==> to display both logical and physical device names

    Ctrl+d  -  to exit the format utility


Disk Partition Tables


# format

format> verify        ==> to read a disks VTOC (Volume Table of Contents)


# prtvtoc /dev/dsk/c0d1s0    ==> to read a disks VTOC

# prtvtoc /dev/dsk/c0d1s2


Relabeling a Disk


# prtvtoc /dev/dsk/c0d1s2 > /var/tmp/c0d1.vtoc    ==> to save a disk’s VTOC to                                 a file


To relabel a disk

# fmthard -s /var/tmp/c0d1.vtoc /dev/rdsk/c0d1s2


To initialize the VTOC of a disk

# fmthard -s /dev/null /dev/rdsk/c0d1s2


# fdisk -W - /dev/rdsk/c0d1p0    ==> to view fdisk partition table details

# fdisk -W /var/tmp/c0d1p0 /dev/rdsk/c0d1p0    ==> to save fdisk partition          details to a file

# fdisk -F /var/tmp/c0d1p0 /dev/rdsk/c0d1p0    ==> to restore fdisk                                 partition table



Solaris Management Console

# smc &        ==> to start Solaris Management Console

# /etc/init.d/init.wbem status    ==> to determine if SMC server is running

# /etc/init.d/init.wbem stop    ==> to stop the SMC server

# /etc/init.d/init.wbem start    ==> to start the SMC server