Remote Backups

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 22.  Backing Up and Restoring the System


If you don't have a tape device installed in all your Sun servers, you may think you will be a bit stuck when it comes to taking backups of the ones without the drives, but it is still possible. If you have an external tape device, you could connect it to each server in turn and take the backup. This may be acceptable in some environments, but for most production environments, something that doesn't have to rely on this kind of manual intervention is usually preferable. Ideally, you will have a tape device on each server, but if you don't, provided your server is on a network along with another that does have a tape drive it will be possible to use that tape drive.

The facility to back up to a remote tape drive is provided by ufsdump/ufsrestore but not by any of the other backup commands we have looked at so far. However, we can still perform a remote backup using the other commands by making use of the remote shell facility with whichever of the above commands you prefer to use.

To make use of the remote shell facility, we must first create a configuration file to enable it. This file is called .rhosts and should be created in the root directory of the machine on which the tape drive is connected. In this file we simply add the names of all the hosts that we want to allow to back up to this tape drive. It should be noted that setting up this file does have security implications. By adding a host to the file, you are allowing the root user of that host to run anything it wants (locally as root). As long as you are aware of this and its implications, then this can be an acceptable solution.

If the drive is connected to the host hydrogen and we want to allow lithium and iodine to back up to the drive, we would create the following .rhosts file in the root directory on hydrogen. (Note that the permissions of this file should be restrictive otherwise somebody could add additional hosts to it and use this to gain access to a root shell.)

 hydrogen# cat /.rhosts lithium root iodine root hydrogen# ls -l /.rhosts -r--------   1 root     other         48 Oct 23 17:46 /.rhosts hydrogen# 

We can test that we have set this up correctly by attempting to run a command on hydrogen from either lithium or iodine:

 lithium# rsh hydrogen tail -1 /etc/shadow msmith:H2hEPH7vDggKX:11649:7:35:14::: lithium# 

We know that everything has worked because only root would have permission to read from the shadow file.

Now we can try to write something to the remote tape drive:

 lithium# tar cvfb - 1024 . | rsh hydrogen dd of=/dev/rmt/0 obs=1024b <lines removed for clarity> lithium# 

Here we are using tar to produce a backup from the current directory and write it to the standard output, rather than a file, and use a block size of 1,024 bytes. The other end of the pipe has a remote shell command, which will be run on the host hydrogen. This runs a dd command, which will read its input from its standard input and write its output to the tape device on hydrogen. The block size is also set to 1,024 bytes.

To restore files we would use the following command:

 lithium# rsh hydrogen dd if=/dev/rmt/0 bs=1024b | tar xvBfb - 1024 . <lines removed for clarity> lithium# 

Here we do the exact opposite. We use rsh to run a dd command on hydrogen that will read its data from the tape device and write it to its standard output (which is a pipe). A local tar command is running at the other end of the pipe, which restores the data into the current directory. The "-B" option tells tar to read its input from a pipe. Again, we specifically set the block size to 1,024 bytes, which ensures that the dd and tar commands are in step with each other.

If you prefer to use cpio, the following example shows how the same thing can be achieved:

 lithium# find . print | cpio -ovcC 2048 | rsh hydrogen dd of=/dev/rmt/0 obs=2048b <lines removed for clarity> lithium# 

To restore from the backup taken using the command above, we would use:

 lithium# rsh hydrogen dd if=/dev/rmt/0 bs=2048b | cpio -ivcdmuC 2048 <lines removed for clarity> lithium# 

The command to perform the backup with cpio is slightly more complex than the tar version, in that it has three pipes, but cpio does not require any special option to read from or write to a pipe. Here we have set the block size to 2,048 bytes.

The following examples show how we can perform a remote backup and recovery using ufsdump and ufsrestore:

 lithium# ufsdump 0f hydrogen:/dev/rmt/0 . <lines removed for clarity> lithium# ufsrestore ivf hydrogen:/dev/rmt/0 <lines removed for clarity> lithium# 

    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net