home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / doc / HOWTO / mini / Backup-With-MSDOS < prev    next >
Internet Message Format  |  1995-01-18  |  15KB

  1. From: Christopher Neufeld <neufeld@physics.utoronto.ca>
  2.  
  3.    Earlier I posed the question on the Net, how does one back up a Linux
  4. machine to a Colorado Jumbo 250 tape drive on an MS-DOS machine. From the
  5. email I received, it seems that this is a frequently pondered problem.
  6. Now that I've figured it out, I'm posting the method. If anybody wants to
  7. massage this into a HOWTO document, let me know. I should thank Jim Nance
  8. (jlnance@isscad.com) for pointing out that an MS-DOS machine need not
  9. always be an MS-DOS machine. This technique should also work for any
  10. other tape drive supported by the ftape module.
  11.    The criteria I set were that the resulting setup should be as secure
  12. as possible and should be fairly simple, and take up little or no space
  13. on the MS-DOS machine's hard drive. It should also be capable of
  14. recovering from the worst system corruptions, up to and including the
  15. theft of the hard disk, requiring a restore to a bare Linux file system.
  16. The technique described here uses no hard drive space on the MS-DOS
  17. machine, though it requires that that machine be assigned an IP#. You
  18. will need three formatted, blank 1.44MB diskettes.
  19.    Throughout this description I will refer to two machines as "msdos"
  20. and "linux". "msdos" is the name of the machine which has the tape drive
  21. and is usually running MS-DOS. "linux" is the Linux machine whose disk
  22. you are trying to back up or restore to the tape drive. For simplicity I
  23. will refer to the first machine as "msdos" even when it is booted into
  24. and running Linux. Further, all path names in this document should be
  25. considered to be relative to the Linux machine with the Search-And-Rescue
  26. (SAR) disks mounted somewhere on the system. That means that the file
  27. /etc/passwd is the password file for your Linux machine's hard drive,
  28. while, for instance, /tape144/etc/passwd is the corresponding file on the
  29. floppy disk.
  30.    I am using Karel Kubat's backup scripts, version 1.03, available at
  31. ftp://sunsite.enc.edu:/pub/Linux/system/Backup/backup-1.03.tar.gz.
  32. Throughout this document I will refer to these simply as "the backup
  33. scripts". You do not have to use these scripts for your own backups to
  34. tape. I like these scripts as they form an uncompressed archive of
  35. compressed files, rather than a compressed archive of uncompressed files.
  36. The former is much safer if there is a media read error during the
  37. restore.
  38.  
  39.    First of all, obtain the ftape module. It is available at:
  40. ftp://sunsite.unc.edu/pub/Linux/kernel/tapes/ftape-1.14d.tar.gz
  41. Next, get a Slackware boot disk (I got the net disk, but it doesn't make
  42. much difference) and the tape144 root disk, and put the images onto 3"1/2
  43. floppies.
  44.    The ftape module will only work if it is installed in the kernel which
  45. was running when you compiled it. I could not get it to work with the
  46. ftape.o module on the tape144 root disk, I think because that module has
  47. been stripped of symbols and won't install. So, you now have to make a
  48. new kernel with network and ftape support, and then a new ftape.o. Read
  49. the directions which ship with the ftape archive for directions at this
  50. stage. Remember that the kernel you compile must support the Ethernet
  51. cards on both the Linux machine and the MS-DOS machine.
  52.    Copy the newly created kernel image over top of the one on the Net
  53. boot disk. Write protect the boot disk, and label it: SAR#1.
  54.  
  55.    Now, mount the tape144 root disk. I'll assume that the mount point is
  56. /tape144, to avoid confusion in file names. We need to free some space
  57. on it, so delete the following files:
  58. /tape144/bin/dialog
  59. /tape144/bin/elvis
  60. /tape144/bin/vi
  61. /tape144/boot/ftape.o
  62.  
  63.    Now, create a new file:
  64. /tape144/etc/exports
  65. which contains the following line:
  66. /mnt    msdos(ro)
  67. Where "msdos" should be replaced with the name or IP# of the MS-DOS
  68. machine which has the tape drive installed.
  69.  
  70.    Next, so that you don't have to rely on a name server, add lines to
  71. the file /tape144/etc/hosts with the names and IP numbers of the Linux
  72. and MS-DOS machines. For instance, mine contains the following two lines:
  73. 128.100.75.114  caliban.physics.utoronto.ca caliban caliban.physics
  74. 128.100.75.111  ariel.physics.utoronto.ca ariel ariel.physics
  75.  
  76.    Now, there's some sort of problem with the inetd configuration. We
  77. have to put the full path name of the rsh daemon in it. Change line 19
  78. of /tape144/etc/inetd.conf to read:
  79. shell   stream  tcp     nowait  root    /usr/etc/tcpd   /usr/etc/in.rshd
  80.  
  81.    Add local net routing information to /tape144/etc/rc.d/rc.inet1 to
  82. enable the MS-DOS machine to use the network. The format of this depends
  83. on your network configuration, you can just copy the appropriate format
  84. out of your Linux /etc/rc.d/rc.inet1. For my network, the lines that
  85. have to be added are:
  86. /etc/ifconfig eth0 128.100.75.111 broadcast 128.100.75.0 netmask 255.255.255.0
  87. /etc/route add -net 128.100.75.0 netmask 255.255.255.0
  88. The IP# in the ifconfig entry is that of the MS-DOS machine.
  89.    Now, copy this file into /tape144/etc/rc.d/rc.inet1-l, and change the
  90. IP# in the new file to reflect that of the Linux machine rather than the
  91. MS-DOS machine.
  92.    Next, clip out lines 3 to 11 of /tape144/etc/rc.local. That's an if
  93. statement which executes the rc.inet* files. We don't want this to
  94. happen during the bootup.
  95.    Create a new file: /tape144/root/.rhosts containing the line:
  96. linux root
  97. where, again, "linux" is replaced with the full machine name (including
  98. domain) or the IP# of the Linux machine.
  99.    Fill in the password field in /tape144/etc/passwd for the root login
  100. to keep people from logging onto the MS-DOS machine while you're doing
  101. the backup. You can do this by copying the corresponding field from your
  102. Linux machine's /etc/passwd file.
  103.    Copy /usr/bin/rsh into /tape144/usr/bin.
  104.    Copy the following files from /usr/etc into /tape144/usr/etc:
  105. in.rshd
  106. rpc.mountd
  107. rpc.nfsd
  108. rpc.portmap
  109. services
  110. tcpd
  111.    Create a new script, /tape144/bin/tapesetup, which consists of the
  112. following: (change "linux" to reflect your Linux machine name).
  113.  
  114. === BEGIN /tape144/bin/tapesetup ===
  115. #! /bin/sh
  116.  
  117. /bin/sh /etc/rc.d/rc.inet1
  118. /bin/sh /etc/rc.d/rc.inet2
  119.  
  120. /bin/mount linux:/nfs /mnt
  121. /bin/insmod /mnt/ftape.o
  122. === END /tape144/bin/tapesetup ===
  123.  
  124.    Next, create another new script, /tape144/bin/msdosset, as follows:
  125. (change "linux" to reflect your Linux machine name).
  126.  
  127. === BEGIN /tape144/bin/msdosset ===
  128. #! /bin/sh 
  129.  
  130. /bin/sh /etc/rc.d/rc.inet1
  131. /bin/sh /etc/rc.d/rc.inet2
  132.  
  133. mount linux:/mnt /mnt
  134. /bin/insmod /mnt/ftape.o
  135. === END /tape144/bin/msdosset ===
  136.  
  137.    Create a readable file, /tape144/root/notes which contains this
  138. helpful information for use in full recovery:
  139.  
  140. === BEGIN /tape144/root/notes ===
  141. For a full recovery to a trashed hard disk, boot the Linux machine with
  142. the SAR disks #1 and #2 then type the following:
  143.  
  144. /bin/sh /etc/rc.d/rc.inet1-l
  145. /bin/sh /etc/rc.d/rc.inet2
  146.  
  147. /usr/etc/rpc.portmap
  148. /usr/etc/rpc.mountd
  149. /usr/etc/rpc.nfsd
  150.  
  151. Next, insert SAR disk #3 and type:
  152.  
  153. mount /dev/fd0 /mnt
  154.  
  155. Create a new mount point, with:
  156. mkdir /mnt2
  157. and mount your Linux hard disk partition on this point. You may have to
  158. reformat the partition first, if so, follow the directions in the Linux
  159. Installation HOWTO. The SAR disks contain all the files necessary to do
  160. the reformat.
  161.  
  162. Finally, use disks SAR#1 and SAR#2 to boot up the MS-DOS machine and run
  163. the /bin/msdosset script on that machine. It will take about a minute to
  164. run that script because it is getting an NSF file from a floppy drive, so
  165. be patient. Now, recover the tape to /mnt2 on the Linux machine.
  166. === END /tape144/root/notes ===
  167.  
  168.    If you are using the backup scripts you will need to copy /bin/su
  169. into the /tape144/bin subdirectory. Copy the backup scripts from your
  170. Linux machine into the corresponding position on /tape144. You do not
  171. need to copy the subdirectories 'lists', 'misc', 'stamps', or 'volumes'
  172. from the /usr/local/etc/backup directory. You will need the other
  173. contents of /usr/local/etc/backup, and also the following files from
  174. /usr/local/bin: 'afio', 'backup', 'backup.bim', 'icm-comp', 'icm-exec',
  175. 'icm-pp', 'icmake', 'netbackup', 'netbackup.bim'. Put these into
  176. /tape144/usr/local/bin.
  177.    I was unable to use the backup scripts as they come shipped. The
  178. tape archive appears to build cleanly, but it is unrecoverable. I found
  179. that removing the block size and conversion statements fixed it. Here is
  180. the patch to the "netbackup" script. Apply this patch to the Linux
  181. machine's hard disk copy of 'netbackup' as well as to the copy on the SAR
  182. disks.
  183.  
  184. === BEGIN /tape144/netbackup.patch ===
  185.  
  186. *** netbackup.orig    Mon Jan  9 17:22:32 1995
  187. --- netbackup    Mon Jan  9 17:23:25 1995
  188. ***************
  189. *** 35,41 ****
  190.                   "'mknod", devname, "p'");
  191.       exec ("su -", USERNAME, "-c",
  192.                   "'rsh ", REMOTE_HOST, 
  193. !                     "\"dd", "of=" REMOTE_DEVICE, "obs=20k", "conv=sync\"",
  194.                       "<", devname,
  195.               "'&"
  196.        );
  197. --- 35,41 ----
  198.                   "'mknod", devname, "p'");
  199.       exec ("su -", USERNAME, "-c",
  200.                   "'rsh ", REMOTE_HOST, 
  201. !                     "\"dd", "of=" REMOTE_DEVICE, "\"",
  202.                       "<", devname,
  203.               "'&"
  204.        );
  205. ***************
  206. *** 50,56 ****
  207.                   "'mknod", devname, "p'");
  208.       exec ("su", USERNAME, "-c", 
  209.                   "'rsh ", REMOTE_HOST, 
  210. !                     "\"dd", "if=" REMOTE_DEVICE, "ibs=20k", "conv=sync\"",
  211.                       ">", devname,
  212.               "'&"
  213.        );
  214. --- 50,56 ----
  215.                   "'mknod", devname, "p'");
  216.       exec ("su", USERNAME, "-c", 
  217.                   "'rsh ", REMOTE_HOST, 
  218. !                     "\"dd", "if=" REMOTE_DEVICE, "\"",
  219.                       ">", devname,
  220.               "'&"
  221.        );
  222.  
  223. === END /tape144/netbackup.patch ===
  224.  
  225.    You have now finished your SAR disk #2. Write protect it.
  226.  
  227.    Next, mount a clean, formatted disk (create it with fdformat and
  228. mkfs). Copy the ftape.o file onto it, and label it SAR#3. For some
  229. reason things go badly if you write protect this disk, so leave it
  230. write-enabled. If you are using the backup scripts, copy /bin/tcsh onto
  231. this disk as well. The backup scripts don't like to run from the version
  232. of bash on the tape144 disk.
  233.  
  234.    On the Linux machine, create a new directory for NFS file serving. I
  235. made a directory:
  236. /nfs
  237. Put the ftape.o (unstripped, about 500+ kB) into this subdirectory.
  238. Create an entry in your Linux's exports file /etc/exports:
  239. /nfs    msdos(ro)
  240. Note that all files in your NFS directory and it's subdirectories are not
  241. secure. Somebody else could boot the MS-DOS machine into Linux with his
  242. own boot disks and mount this directory, so be certain that you don't put
  243. anything sensitive in your NFS subdirectory.
  244.    Restart your NFS daemons, rpc.mountd and rpc.nfsd. They don't seem to
  245. take kindly to a SIGHUP restart, so kill them and reinvoke them. If
  246. you're not activating these daemons in your /etc/rc.d/rc.inet2 you might
  247. want to do so now.
  248.  
  249.  
  250.    OK, now we're all set to back up and recover. To make a full backup
  251. from the Linux machine, boot the MS-DOS machine with SAR#1. When
  252. prompted for the second disk, load SAR#2. Log in as root, and execute
  253. the script: /bin/tapesetup. Log out of the MS-DOS machine. If you're
  254. using the backup scripts, the netbackup command will now work. You can
  255. also use the "-f msdos:/dev/ftape" switch on GNU tar, cpio, or mt, and
  256. make your backup this way. If you have a backup program which is only
  257. capable of writing to a local file, do the following. Assume that the
  258. backup program is called "localbackup" and writes to the file
  259. represented by its command line argument:
  260.  
  261. mknod /tmp/tapepipe p
  262. rsh msdos dd of=/dev/ftape < /tmp/tapepipe &
  263. localbackup /tmp/tapepipe
  264.  
  265. when it's done, delete /tmp/tapepipe.
  266.  
  267.    Recovering to a live Linux machine: the netbackup script, tar, cpio,
  268. and so on will all work without special actions on the part of the
  269. operator. If you have a local recovery program which recovers from a
  270. file, do this:
  271.  
  272. mknod /tmp/tapepipe p
  273. rsh -n msdos dd if=/dev/ftape >> /tmp/tapepipe &
  274. localrecovery /tmp/tapepipe
  275.  
  276. and delete /tmp/tapepipe when you're done.
  277.    Notice that I'm using 'rsh' to the root user on the MS-DOS machine.
  278. This works with a correct .rhosts entry. The configuration on the
  279. 'tape144' disk allows rsh to root, but does not allow telnet or rlogin to
  280. root, logins are restricted to the console. This is good for security.
  281.  
  282.    Finally, the directions for a complete recovery to a trashed hard
  283. disk. This assumes that the Linux partition is completely unrecoverable.
  284. If necessary, reformat that partition as described in the Linux
  285. Installation HOWTO. Boot the Linux machine from SAR disk #1. When
  286. prompted, insert disk #2. Now, follow the directions in the file
  287. /root/notes (this was /tape144/root/notes when it was mounted on your
  288. Linux machine). Once both machines have been booted up, run the recovery
  289. routine you need. If you are running the backup scripts you have to do it
  290. from tcsh, so type "/mnt/tcsh" before you use the "netbackup -restore \*"
  291. function. Remember to change the working directory to the mount point of
  292. the hard disk before running netbackup.
  293.  
  294.  
  295.    Notes:
  296.  
  297.    The commands listed in the /tape144/root/notes file could be run from
  298. a script. When I tried, I got rpc setup errors. I suspect it was just
  299. that the commands were run too quickly, and the portmapper hadn't
  300. properly installed itself. I found that typing the sequence in manually
  301. worked fine, so I've recommended that.
  302.    I think this setup is secure. Note that somebody can still get access
  303. to all your files if they go to the tape drive and pull the tape out
  304. before you get there, then then read the tape themselves. People with very
  305. sensitive data might consider encrypting the stream from the archiver.
  306. Archive to standard output and pipe the output to the encrypter, and
  307. redirect the output of the encrypter to append to the named pipe
  308. /tmp/tapepipe as described above.
  309.    The rc.inet1 directions I've included will allow only communication
  310. with the local network, not the rest of the world through a gateway.
  311.    During a full recovery to a blank hard disk the SAR disk #3 provides
  312. ftape.o to the MS-DOS machine through NFS. This is because some old
  313. versions of the ftape module can't control some tape drives when there is
  314. a disk mounted in the floppy drive.
  315.  
  316.    This is very important. ***TEST*** the SAR recovery procedure. I did,
  317. but don't leave anything to chance. Make sure that you can recover at
  318. least one file from your tape to the Linux machine using only the SAR
  319. disks (ie. without mounting the hard disk). If you can't reboot the Linux
  320. machine without inconveniencing a lot of users, change the setup
  321. information on the SAR disks to assign the "linux" identity to another
  322. MS-DOS machine and then boot the two MS-DOS machines into Linux to make
  323. sure everything works. Then, change the "linux" identity back again so
  324. that you have usable SAR disks.
  325.  
  326.  
  327. Copyright Jan 10, 1995 by Christopher Neufeld (neufeld@physics.utoronto.ca)
  328.  
  329.  
  330. -- 
  331.  Christopher Neufeld....Just a graduate student   neufeld@physics.utoronto.ca
  332.  Home page:  http://caliban.physics.utoronto.ca/neufeld/Intro.html
  333.  "Don't edit reality for the sake of simplicity"
  334.  
  335.