How to back up a hard disk to a tape drive over the Network.


Steps to backing up a hard drive to tape.

The tape drive is attached to bak.code-donkey.org.

1. Place a data tape into the tape drive.
2. Write down the order of the partitions which you are going to backup. Use the /etc/fstab of the remote box [the box you are backing up] as a guide. Write this informantion and the date on the tape. You will need this information when you restore the backed up data. Also indecate what type of disk drive you are backing up [scsi or ide].
3. Be sure that there is a .rhosts file in the /root of the remote box. This should have an entrie of:
bak.code-donkey.org root
Be sure that the premissions of the .rhosts is restricted only to root:
chmod 600 /root/.rhosts
You will also need to have an entrie of the remote box in the /root/.rhosts on bak.code-donkey.org:
hostname.code-donkey.org root
4. This is an example of the string used to backup "/dev/hda5" to the tape drive "/dev/nst0" over the network.
rsh xxx.code-donkey.org "/sbin/dump -0ua -f root@bak.code-donkey.org:/dev/nst0 /dev/hda5"


USED ON BAK

1. To be sure that the connectons can be establised you should rsh to the remote box [the box which is being backed up] from the box which hosts the tape drive. Also rsh to the the box which hosts the tape drive from the remote box.
It would also be helpful to have a copy of the orignal /etc/fstab.

An example:

rsh xxxxxx.code-donkey.org "/sbin/dump -0ua -f root@bak.code-donkey.org:/dev/nst0 /dev/hda5"
[the host you bk up] [id][host the tape is on] [tape] [partition]

- The tape drive uses the device /dev/nst0.

- restore -if /dev/nst0

restore uses "tape" as opposed to "/dev/nst0" so you may need to link /dev/nst0 to /dev/tape.
The default tape device is /dev/st0 - I beleave /st0 is rewindable.
- restore -if /dev/nst0
If you do not use -f the restore will use /dev/tape as the dump device.
- restore -i /dev/tape
This commnand allows you to look "interactively" at what is on the tape. You might needed to rewind the tape first.

First:

ln -s /dev/nst0 tape
then:
mt load
then:
mt status
then:
restore -if /dev/tape
This will show what is on the tape, and put you into a shell, which will allow you to run certin commands.

Now Trying to Restore the Tape.

From the backup box, bak.code-donkey.org:

rsh tmp1.code-donkey.org "/sbin/restore -i cd /box -h -f root@bak.code-donkey.org:/dev/nst0"

Test:

/sbin/restore -if /dev/st0
it then did:
spcl.c_filesys = /
dirptr = (null)
dirptr = (null)
filesys = /
/sbin/restore >

So I typed "help" and got a list of instructions. I cd into the /home on the tape.

Then I typed:

add httpd
- then useing ls I saw an "*" beside httpd. At this point I typed:
extract
I was then prompted for the volume number [tape], as there is only one tape I typed 1. If there were more than one tape, I would do the first one, then when asked for the next tape I would put in the last one, and from then on, I would work BACKWARDS. For example 6,5,4,3,2, etc..

Specify next volume #: 1

If you are going to do a full restore you donot want to be in "interactive mode"

When the "extract" was done, I answered "yes" to "set owner/mode for '.'? [yn] y"

LATTE

Latte /etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/da0s1b none swap sw 0 0
/dev/da0s1a / ufs rw 1 1
/dev/da0s1f /usr ufs rw 2 2
/dev/da0s1e /var ufs rw 2 2
proc /proc procfs rw 0 0

From BAK

backing up / partition.

rsh latte.code-donkey.org "/sbin/dump -0ua -f root@bak.code-donkey.org:/dev/nst0 /dev/da0s1a"

backing up /usr partition.

rsh latte.code-donkey.org "/sbin/dump -0ua -f root@bak.code-donkey.org:/dev/nst0 /dev/da0s1f"

backing up /var partition.

In this ittration I changed the tape device to /dev/st0 which is rewindable.
rsh latte.code-donkey.org "/sbin/dump -0ua -f root@bak.code-donkey.org:/dev/st0 /dev/da0s1e"

Makeing a new File System [fs] and restoring the backups to disk.


Thease instructions are for restoring a dump to a new hard disk.
You should add either an additional scsi drive or ide drive to a functioning box.

As root; run:
  • /stand/sysinstall

  • Select #5 [Configure] from the menue.
  • Then select "Fdisk", and within "Fdisk" choose the slave drive which you want to do the restore to. If you choose the wrong drive, you could eface your file system. Use the space bar to select the drive.
    If a partition exists on the drive delete it, and recreate one by pressing "A" for the entire disk. Do not make the disk "bootable."
  • Now press "Q" to quit.
  • The next page will show you some Boot Manager options. Select the standard boot manager.
  • Next you will need to make the "Label." Select "Label from the menue options.

    Create:
    200m / [fs]
    400m swap
    200m /var [fs]
    use the remainder for /usr [fs]

  • At this point "write" the information. The box will probably panic and reboot. Then once it is back up. Return to /stand/sysinstall, and go back to "Label". Now highlight each partition, they will no longer have their mount points, so recreate them useing the "M" option.
  • When you have recreated the labels, then press "Q" for quit.
    Now back out of the menueing system.

    Next you will need to run the new fs command. See below.

    To make a new fs and restore with a tape drive which is directly conneted to the router you:
    Do this for each partition.

    SCSI
    newfs /dev/da1s1a [/]
    newfs /dev/da1s1b [swap]
    newfs /dev/da1s1f [/usr]
    newfs /dev/da1s1e [/var]

    IDE
    newfs /dev/wd1s1a [/]
    newfs /dev/wd1s1b [swap]
    newfs /dev/wd1s1f [/usr]
    newfs /dev/wd1s1e [/var]


    See the man page on restore.


    Make sure that you "restore" in the same order which you did the "dump" in. So it would be /dev/da1s1a, /dev/da1s1f, /dev/da1s1e. Also notice that thease slices are for a secondery disk. So when the files have been reinstlled they should be for a primary disk "da0" not "da1".

    This has only been tested on FreeBSD-3.4 and Linux Red Hat 6.2 boxes.

    There may be some RSA issues with later verions. I strongly recomend useing SSH if possable.

    For refernce see the MAN pages on:

    dump
    restore
    mt

    - Each host should have a /root/.rhosts file setup for the approprate computers.

    eg:
    name.domain root
    Be sure to do a chmod 600 .rhosts to keep the file readable only by root.

    The "mt" commands are done on the computer which is hosting the tape drive.

    INSTALLING THE / PARTITION.


    If you are doing a full dump, be sure to start in the right order. Always put on the tape the order in which you did the DUMP. Then Restore it following the same order.

    mount /dev/da1s1a /mnt [scsi]
    mount /dev/wd1s1a /mnt [ide]

    Then do a "df" on the box which is houseing the new disk to be sure the partition has mounted to /mnt. If /mnt dose not show up it means the partition did not mount. :)

    Now:
    cd /mnt

    Installing "/":

    rsh milk.code-donkey.org -use this if you are not connected to the box which is hosting the disk which is being restored.-

    [scsi]

    /sbin/restore -rf root@bak.code-donkey.org:/dev/nst0 /dev/da0s1a

    [ide]

    /sbin/restore -rf root@bak.code-donkey.org:/dev/nst0 /dev/wd0s1a

    INSTALLING THE /usr PARTITION.


    You should not need to move the tape to the next postition. Provided you are following the order which the partitions were backed up. Always check the partition after you have restored it, so that you can be sure the correct information was installed on the partition.
    "mt fsf" is used to move the tape to the first block of the next file. It will move you from / to /usr on the tape.

    You need to dismount /dev/da1s1a [or /dev/wd1s1a] from /mnt and then mount the next partition to /mnt

    cd / [You can not dismount a partition while you are it.]
    umount /mnt

    mount /dev/da1s1f /mnt [scsi]
    mount /dev/wd1s1f /mnt [ide]

    Then do a "df" to be sure the partition has mounted.

    Now:
    cd /mnt

    Then:

    Installing "/usr":

    rsh milk.code-donkey.org -use this if you are not connetcte to the box which is hosting the disk which is being restored.-

    [scsi]

    /sbin/restore -rf root@bak.code-donkey.org:/dev/nst0 /dev/da0s1f

    [ide]

    /sbin/restore -rf root@bak.code-donkey.org:/dev/nst0 /dec/wd0s1f

    INSTALLING THE /var PARTITION.


    mt fsf is used to move the tape to the first block of the next file. It too move you from / to /usr on the tape.

    You need to dismount /dev/da1s1f from /mnt and then mount the next partition to /mnt

    cd /
    umount /mnt
    mount /dev/da1s1e /mnt [scsi]
    mount /dev/wd1s1e /mnt [scsi]
    Then do a "df" to be sure the partition has mounted.
    Now:
    cd /mnt

    Installing "/var":

    rsh milk.code-donkey.org -use this if you are not connetcte to the box which is hosting the disk which is being restored.-

    [scsi]

    /sbin/restore -rf root@bak.code-donkey.org:/dev/nst0 /dev/da0s1e

    [ide]

    /sbin/restore -rf root@bak.code-donkey.org:/dev/nst0 /dev/wd0s1e

  • A. Aakesson 05/23/01.