home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / DOC / HOWTO / MINI / BACKUP_W < prev    next >
Encoding:
Text File  |  1996-02-06  |  15.8 KB  |  361 lines

  1. Backup-With-MSDOS mini-HOWTO
  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 use afio to form an uncompressed
  35. archive of compressed files, rather than a compressed archive of
  36. uncompressed files. The former is much safer if there is a media read
  37. error during the restore. I understand that Karel is no longer supporting
  38. backup, and now has produced 'tob', or tape oriented backup. While I
  39. haven't tried the new package myself, it cannot make a significant
  40. difference to the procedure outlined here.
  41.  
  42.    First of all, obtain the ftape module. It is available at:
  43. ftp://sunsite.unc.edu/pub/Linux/kernel/tapes/ftape-2.05.tar.gz
  44. Next, get a Slackware boot disk (I got the net disk, but it doesn't make
  45. much difference) and the tape144 root disk, and put the images onto 3"1/2
  46. floppies.
  47.    The ftape module will only work if it is installed in the kernel which
  48. was running when you compiled it. I could not get it to work with the
  49. ftape.o module on the tape144 root disk, I think because that module has
  50. been stripped of symbols and won't install. So, you now have to make a
  51. new kernel with network and ftape support (if applicable, recent versions
  52. of ftape do not need kernel support, and recent kernels do not offer the
  53. option), and then a new ftape.o. Read the directions which ship with the
  54. ftape archive for directions at this stage. Remember that the kernel you
  55. compile must support the Ethernet cards on both the Linux machine and the
  56. MS-DOS machine.
  57.    Copy the newly created kernel image over top of the one on the Net
  58. boot disk. Use /bin/cp, do not create a boot disk with the "dd" command
  59. as you would to create a bootable kernel image. Write protect the boot
  60. disk, and label it: SAR#1.
  61.  
  62.    Now, mount the tape144 root disk. I'll assume that the mount point is
  63. /tape144, to avoid confusion in file names. We need to free some space
  64. on it, so delete the following files:
  65. /tape144/bin/dialog
  66. /tape144/bin/elvis
  67. /tape144/bin/vi
  68. /tape144/boot/ftape.o
  69.  
  70.    Now, create a new file:
  71. /tape144/etc/exports
  72. which contains the following line:
  73. /mnt    msdos(ro)
  74. Where "msdos" should be replaced with the name or IP# of the MS-DOS
  75. machine which has the tape drive installed.
  76.  
  77.    Next, so that you don't have to rely on a name server, add lines to
  78. the file /tape144/etc/hosts with the names and IP numbers of the Linux
  79. and MS-DOS machines. For instance, mine contains the following two lines:
  80. 128.100.75.114  caliban.physics.utoronto.ca caliban caliban.physics
  81. 128.100.75.111  ariel.physics.utoronto.ca ariel ariel.physics
  82.  
  83.    Now, there's some sort of problem with the inetd configuration. We
  84. have to put the full path name of the rsh daemon in it. Change line 19
  85. of /tape144/etc/inetd.conf to read:
  86. shell   stream  tcp     nowait  root    /usr/etc/tcpd   /usr/etc/in.rshd
  87.  
  88.    Add local net routing information to /tape144/etc/rc.d/rc.inet1 to
  89. enable the MS-DOS machine to use the network. The format of this depends
  90. on your network configuration, you can just copy the appropriate format
  91. out of your Linux /etc/rc.d/rc.inet1. For my network, the lines that
  92. have to be added are:
  93. /etc/ifconfig eth0 128.100.75.111 broadcast 128.100.75.0 netmask 255.255.255.0
  94. /etc/route add -net 128.100.75.0 netmask 255.255.255.0
  95. The IP# in the ifconfig entry is that of the MS-DOS machine.
  96.    Now, copy this file into /tape144/etc/rc.d/rc.inet1-l, and change the
  97. IP# in the new file to reflect that of the Linux machine rather than the
  98. MS-DOS machine.
  99.    Next, clip out lines 3 to 11 of /tape144/etc/rc.local. That's an if
  100. statement which executes the rc.inet* files. We don't want this to
  101. happen during the bootup.
  102.    Create a new file: /tape144/root/.rhosts containing the line:
  103. linux root
  104. where, again, "linux" is replaced with the full machine name (including
  105. domain) or the IP# of the Linux machine.
  106.    Fill in the password field in /tape144/etc/passwd for the root login
  107. to keep people from logging onto the MS-DOS machine while you're doing
  108. the backup. You can do this by copying the corresponding field from your
  109. Linux machine's /etc/passwd file.
  110.    Copy /usr/bin/rsh into /tape144/usr/bin.
  111.    Copy the following files from /usr/etc into /tape144/usr/etc:
  112. in.rshd
  113. rpc.mountd
  114. rpc.nfsd
  115. rpc.portmap
  116. services
  117. tcpd
  118.    Create a new script, /tape144/bin/tapesetup, which consists of the
  119. following: (change "linux" to reflect your Linux machine name).
  120.  
  121. === BEGIN /tape144/bin/tapesetup ===
  122. #! /bin/sh
  123.  
  124. /bin/sh /etc/rc.d/rc.inet1
  125. /bin/sh /etc/rc.d/rc.inet2
  126.  
  127. /bin/mount linux:/nfs /mnt
  128. /bin/insmod /mnt/ftape.o
  129. === END /tape144/bin/tapesetup ===
  130.  
  131.    Next, create another new script, /tape144/bin/msdosset, as follows:
  132. (change "linux" to reflect your Linux machine name).
  133.  
  134. === BEGIN /tape144/bin/msdosset ===
  135. #! /bin/sh 
  136.  
  137. /bin/sh /etc/rc.d/rc.inet1
  138. /bin/sh /etc/rc.d/rc.inet2
  139.  
  140. mount linux:/mnt /mnt
  141. /bin/insmod /mnt/ftape.o
  142. === END /tape144/bin/msdosset ===
  143.  
  144.    Create a readable file, /tape144/root/notes which contains this
  145. helpful information for use in full recovery:
  146.  
  147. === BEGIN /tape144/root/notes ===
  148. For a full recovery to a trashed hard disk, boot the Linux machine with
  149. the SAR disks #1 and #2 then type the following:
  150.  
  151. /bin/sh /etc/rc.d/rc.inet1-l
  152. /bin/sh /etc/rc.d/rc.inet2
  153.  
  154. /usr/etc/rpc.portmap
  155. /usr/etc/rpc.mountd
  156. /usr/etc/rpc.nfsd
  157.  
  158. Next, insert SAR disk #3 and type:
  159.  
  160. mount /dev/fd0 /mnt
  161.  
  162. Create a new mount point, with:
  163. mkdir /mnt2
  164. and mount your Linux hard disk partition on this point. You may have to
  165. reformat the partition first, if so, follow the directions in the Linux
  166. Installation HOWTO. The SAR disks contain all the files necessary to do
  167. the reformat.
  168.  
  169. Finally, use disks SAR#1 and SAR#2 to boot up the MS-DOS machine and run
  170. the /bin/msdosset script on that machine. It will take about a minute to
  171. run that script because it is getting an NSF file from a floppy drive, so
  172. be patient. Now, recover the tape to /mnt2 on the Linux machine.
  173. === END /tape144/root/notes ===
  174.  
  175.    If you are using the backup scripts you will need to copy 'afio' into
  176. the /tape144/local/bin subdirectory. It is not necessary to have the rest
  177. of the backup script files on the recovery disks, an archive can be
  178. recovered using only 'afio' and 'gzip'.
  179.    I was unable to use the backup scripts as they come shipped. The
  180. tape archive appears to build cleanly, but it is unrecoverable. I found
  181. that removing the block size and conversion statements fixed it. Here is
  182. the patch to the "netbackup" script. Apply this patch to the Linux
  183. machine's hard disk copy of 'netbackup' as well as to the copy on the SAR
  184. disks.
  185.  
  186. === BEGIN /tape144/netbackup.patch ===
  187.  
  188. *** netbackup.orig    Mon Jan  9 17:22:32 1995
  189. --- netbackup    Mon Jan  9 17:23:25 1995
  190. ***************
  191. *** 35,41 ****
  192.                   "'mknod", devname, "p'");
  193.       exec ("su -", USERNAME, "-c",
  194.                   "'rsh ", REMOTE_HOST, 
  195. !                     "\"dd", "of=" REMOTE_DEVICE, "obs=20k", "conv=sync\"",
  196.                       "<", devname,
  197.               "'&"
  198.        );
  199. --- 35,41 ----
  200.                   "'mknod", devname, "p'");
  201.       exec ("su -", USERNAME, "-c",
  202.                   "'rsh ", REMOTE_HOST, 
  203. !                     "\"dd", "of=" REMOTE_DEVICE, "\"",
  204.                       "<", devname,
  205.               "'&"
  206.        );
  207. ***************
  208. *** 50,56 ****
  209.                   "'mknod", devname, "p'");
  210.       exec ("su", USERNAME, "-c", 
  211.                   "'rsh ", REMOTE_HOST, 
  212. !                     "\"dd", "if=" REMOTE_DEVICE, "ibs=20k", "conv=sync\"",
  213.                       ">", devname,
  214.               "'&"
  215.        );
  216. --- 50,56 ----
  217.                   "'mknod", devname, "p'");
  218.       exec ("su", USERNAME, "-c", 
  219.                   "'rsh ", REMOTE_HOST, 
  220. !                     "\"dd", "if=" REMOTE_DEVICE, "\"",
  221.                       ">", devname,
  222.               "'&"
  223.        );
  224.  
  225. === END /tape144/netbackup.patch ===
  226.  
  227.    You have now finished your SAR disk #2. Write protect it.
  228.  
  229.    Next, mount a clean, formatted disk (create it with fdformat and
  230. mkfs). Copy the ftape.o file onto it, and label it SAR#3. For some
  231. reason things go badly if you write protect this disk, so leave it
  232. write-enabled.
  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. If
  281. you are worried about a root .rhost file, you can create a new user on
  282. SAR#2, "tapeuser", with permissions to operate the tape drive but not the
  283. disks (create a new group and put tapeuser in that group, then chown and
  284. chmod the files /dev/rft* and /dev/nrft*). Your backup program then has
  285. to know to rsh to that username rather than to root. Of course, now there
  286. must be an .rhosts file in ~tapeuser on SAR#2. For my own use, I have
  287. chosen this course, rather than a root .rhosts.
  288.  
  289.    Finally, the directions for a complete recovery to a trashed hard
  290. disk. This assumes that the Linux partition is completely unrecoverable.
  291. If necessary, reformat that partition as described in the Linux
  292. Installation HOWTO. Boot the Linux machine from SAR disk #1. When
  293. prompted, insert disk #2. Now, follow the directions in the file
  294. /root/notes (this was /tape144/root/notes when it was mounted on your
  295. Linux machine). Once both machines have been booted up, run the recovery
  296. routine you need. If you are running the backup scripts you can do it as
  297. follows:
  298. 1) change directory to the mount point of the hard disk partition which
  299. you will be recovering.
  300. 2) if any mounted volumes are on the backup, and you want to recover
  301. them, create the mount points within the hard disk partition and mount
  302. the volumes.
  303. 3) Enter the command:
  304. rsh -n msdos dd if=/dev/ftape | afio -i -v -Z -c 1024 -
  305.  
  306. or
  307.  
  308. rsh -n -l tapeuser msdos dd if=/dev/ftape | afio -i -v -Z -c 1024 -
  309.  
  310. or
  311.  
  312. mknod /tmp/backpipe p
  313. rsh -n msdos dd if=/dev/ftape >> /tmp/backpipe &
  314. afio -i -v -Z -c 1024 /tmp/backpipe
  315.  
  316. This reads the tape on the remote machine, writing the result to stdout,
  317. where afio picks it up. The '-i' switch tells it to recover the files
  318. relative to the current working directory (which is the root of the hard
  319. disk partition). '-v' is verbose, listing the files as they are
  320. recovered. '-Z' tells afio that this is an archive of individually
  321. compressed files. '-c 1024' tells it to use a 5 MB streaming buffer to
  322. avoid a lot of tape rewinding.
  323.  
  324.  
  325.  
  326.    Notes:
  327.  
  328.    The commands listed in the /tape144/root/notes file could be run from
  329. a script. When I tried, I got rpc setup errors. I suspect it was just
  330. that the commands were run too quickly, and the portmapper hadn't
  331. properly installed itself. I found that typing the sequence in manually
  332. worked fine, so I've recommended that.
  333.    I think this setup is secure. Note that somebody can still get access
  334. to all your files if they go to the tape drive and pull the tape out
  335. before you get there, then then read the tape themselves. People with very
  336. sensitive data might consider encrypting the stream from the archiver.
  337. Archive to standard output and pipe the output to the encrypter, and
  338. redirect the output of the encrypter to append to the named pipe
  339. /tmp/tapepipe as described above.
  340.    The rc.inet1 directions I've included will allow only communication
  341. with the local network, not the rest of the world through a gateway.
  342.    During a full recovery to a blank hard disk the SAR disk #3 provides
  343. ftape.o to the MS-DOS machine through NFS. This is because some old
  344. versions of the ftape module can't control some tape drives when there is
  345. a disk mounted in the floppy drive.
  346.  
  347.    This is very important. ***TEST*** the SAR recovery procedure. I did,
  348. but don't leave anything to chance. Make sure that you can recover at
  349. least one file from your tape to the Linux machine using only the SAR
  350. disks (ie. without mounting the hard disk). If you can't reboot the Linux
  351. machine without inconveniencing a lot of users, change the setup
  352. information on the SAR disks to assign the "linux" identity to another
  353. MS-DOS machine and then boot the two MS-DOS machines into Linux to make
  354. sure everything works. Then, change the "linux" identity back again so
  355. that you have usable SAR disks.
  356.  
  357.  
  358. Copyright Jan 10, 1995 by Christopher Neufeld (neufeld@physics.utoronto.ca)
  359.  
  360. Modified Feb 6, 1996.
  361.