Changeset 562


Ignore:
Timestamp:
May 20, 2006, 10:31:41 PM (13 years ago)
Author:
bcornec
Message:

Integration of Conor Daly's HOWTO deal with cron in mondorescue doc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo-doc/mondorescue-howto.sgml

    r543 r562  
    4040<affiliation>
    4141<orgname>MondoRescue Project</orgname>
    42 <address><email>bcornec@users.berlios.de</email></address>
     42<address><email>bruno@mondorescue.org</email></address>
     43</affiliation>
     44</author>
     45<author>
     46<firstname>Conor</firstname>
     47<surname>Daly</surname>
     48<affiliation>
     49<orgname>MondoRescue Project</orgname>
     50<address><email>conor.daly_at_met.ie</email></address>
    4351</affiliation>
    4452</author>
     
    5462<copyright>
    5563<year>2000-2006</year>
    56 <holder role="mailto:bcornec@users.berlios.de">Bruno Cornec</holder>
     64<holder role="mailto:bruno@mondorescue.org">Bruno Cornec</holder>
    5765</copyright>
    5866
     
    7785
    7886<revhistory>
     87<revision>
     88    <revnumber>2.0.7</revnumber>
     89    <date>2006-05-16</date>
     90    <authorinitials>Bruno Cornec</authorinitials>
     91    <revdescription>
     92    <para>
     93    Integration of a chapter on HOWTO run mondo interactively using cron written by Conor Daly
     94    </para>
     95    </revdescription>
     96</revision>
    7997<revision>
    8098    <revnumber>2.06</revnumber>
     
    466484
    467485        bash# mindi
     486</entry>
     487</row>
     488<row>
     489<entry>
    468490        bash# cd /root/images/mindi
    469491
     
    547569
    548570        bash# mkdir -p /mnt/nfs
     571</entry>
     572</row>
     573<row>
     574<entry>
    549575        bash# mount 192.168.1.28:/home/nfs /mnt/nfs
    550         bash# mondoarchive -OVn 192.168.1.28:/home/nfs -gF[...]
    551         bash# umount /mnt/nfs
    552         bash# cdrecord dev=0,0,0 speed=4 -eject -v /root/images/mindi/mindi.iso
     576        </entry>
     577</row>
     578<row>
     579<entry>
     580bash# mondoarchive -OVn 192.168.1.28:/home/nfs -gF[...]
     581        </entry>
     582</row>
     583<row>
     584<entry>
     585bash# umount /mnt/nfs
     586        </entry>
     587</row>
     588<row>
     589<entry>
     590bash# cdrecord dev=0,0,0 speed=4 -eject -v /root/images/mindi/mindi.iso
    553591
    554592</entry>
     
    939977
    940978        bash# cd /tmp
     979</entry>
     980</row>
     981<row>
     982<entry>
    941983        bash# tar -zxvf mindi-1.x.tgz
    942         bash# cd mindi-1.x
     984        </entry>
     985</row>
     986<row>
     987<entry>
     988bash# cd mindi-1.x
     989</entry>
     990</row>
     991<row>
     992<entry>
    943993        bash# ./install.sh
    944994
     
    9571007
    9581008bash# rpm -Uvh /tmp/mindi-1.x-x.i386.rpm
     1009</entry>
     1010</row>
     1011<row>
     1012<entry>
    9591013
    9601014or
     1015</entry>
     1016</row>
     1017<row>
     1018<entry>
    9611019
    9621020bash# dpkg -i /tmp/mindi-1.x-x.deb
     
    9811039
    9821040        bash# cd /tmp
     1041</entry>
     1042</row>
     1043<row>
     1044<entry>
    9831045        bash# tar -zxvf mondo-2.xx.tgz
    984         bash# cd mondo-2.xx
    985         bash# make &amp;&amp; make install
     1046        </entry>
     1047</row>
     1048<row>
     1049<entry>
     1050bash# cd mondo-2.xx
     1051        </entry>
     1052</row>
     1053<row>
     1054<entry>
     1055bash# make &amp;&amp; make install
    9861056
    9871057</entry>
     
    10001070
    10011071bash# rpm -Uvh /tmp/mondo-2.x-x.i386.rpm
     1072</entry>
     1073</row>
     1074<row>
     1075<entry>
    10021076
    10031077or
     1078</entry>
     1079</row>
     1080<row>
     1081<entry>
    10041082
    10051083bash# dpkg -i /tmp/mondo-2.x-x.deb
     
    10531131create boot disks, and to create a bootable CD image:</para>
    10541132<para></para>
    1055 <informaltable><tgroup cols="1"><tbody>
    1056 <row>
    1057 <entry>
     1133<screen>
    10581134
    10591135# mindi
     
    11221198#
    11231199       
    1124 </entry>
    1125 </row>
    1126 </tbody></tgroup></informaltable>
     1200</screen>
    11271201
    11281202<para>If your kernel is too large (more than about 900KB) then you
     
    11391213
    11401214        bash# cd /root/images/mindi
     1215</entry>
     1216</row>
     1217<row>
     1218        <entry>
    11411219        bash# cdrecord -scanbus
    11421220
     
    12381316<para>Find the speed/compression
    12391317compromise that best suits your needs. Here maximum (-9) compression level is used.</para>
    1240 <para>If you are using cron then please use -F to make sure that
    1241 Mondo does not prompt you to create bootable floppy disks. Cron
    1242 does not handle user interaction well because it pipes stdin and
    1243 stdout specially. Please consult cron's manual for more
    1244 information. Jesse Keating has written a script for cron/Mondo
    1245 users. It is available on the
    1246 <ulink url="http://www.mondorescue.org/docs/docs.html">Documentation</ulink>
    1247 page.</para>
     1318<para>If you are using cron then please consult the chapter that Conor Daly has dedicated to that <link linkend="backup-cron">topic</link>
     1319</para>
    12481320</sect1>
    12491321
     
    13581430
    13591431        bash# mount 192.168.1.3:/home/nfs -t nfs /mnt/nfs
     1432</entry>
     1433</row>
     1434<row>
     1435        <entry>
    13601436        bash# mondoarchive -OVn 192.168.1.3:/home/nfs -g -s 200m
     1437</entry>
     1438</row>
     1439<row>
     1440        <entry>
    13611441        bash# umount /mnt/nfs
    13621442
     
    13741454        your mindi package.
    13751455</para>
     1456</sect2>
     1457</sect1>
     1458</chapter>
     1459
     1460<chapter id="backup-cron">
     1461<title>HOWTO run mondo interactively using cron</title>
     1462
     1463<sect1 id="backup-cron-overview">
     1464<title>Overview</title>
     1465
     1466<para>
     1467        Mondoarchive is designed to run interactively (at least where
     1468 media changes are necessary). Cron does not allow user interaction
     1469 with a job. This section addresses the problem by using screen as a
     1470 wrapper for mondo.
     1471</para>
     1472<para>
     1473        This section is Copyright 2003 Conor Daly.
     1474</para>
     1475</sect1>
     1476<sect1 id="backup-cron-intro">
     1477        <title>Introduction</title>
     1478
     1479<para>
     1480Mondoarchive is designed to run interactively. That's not strictly
     1481 true, if you run mondoarchive without the '-g' switch, it will just
     1482 run. However, there is a problem where media changes are necessary.
     1483 The user must change the media and tell mondoarchive that the change
     1484 has been done. The problem lies in the fact that cron does not allow
     1485 user interaction with a job. If you schedule a mondoarchive job via
     1486 cron, you better be sure it needs only one media. in practical terms,
     1487 this means using tapes or ISOs (if CD-R(W) is your backup medium).
     1488 However, for tape users, there's always the possibility that the
     1489 backup will overflow the tape while for CD-R(W) users, there is the
     1490 added hassle of burning the ISOs in the morning. If your CD_R(W)
     1491 backup routinely occupies more than one media, this is not for you
     1492 (use the ISO option and burn the CDs in the morning). This HOWTO
     1493 addresses the problem by using screen as a wrapper for mondo.
     1494</para>
     1495</sect1>
     1496<sect1 id="backup-cron-who">
     1497        <title>Who should read this?</title>
     1498<sect2><title>Insurance</title>
     1499<para>
     1500Mondo users who wish to automate the backup and whose backups
     1501 routinely occupy close to one media are the best audience. If you
     1502 backup to tape, the occasion will arise when the backup will overflow
     1503 your tape. In this instance, mondoarchive will ask for another tape.
     1504 If you're using cron to start the backup, you won't be able to tell
     1505 mondo that the new tape is mounted and the backup will fail. If you
     1506 backup to CD-R(W), the same situation will arise but sooner.
     1507 </para>
     1508 </sect2>
     1509 <sect2><title>Efficiency</title>
     1510<para>
     1511If your backup already occupies two media, this method will allow
     1512 as much of the backup as possible to proceed during quiet periods.
     1513 Time the backup to start wich enough time to complete the first media
     1514 shortly before the operator arrives for work. The next media can
     1515 be mounted and the backup completed asap and minimises the time for
     1516 which users are inconvenienced by the backup (eg. database locked...).
     1517 </para>
     1518 </sect2>
     1519 </sect1>
     1520 <sect1 id="backup-cron-problem">
     1521         <title>The Problem</title>
     1522<sect2><title>Cron's environment</title>
     1523<para>
     1524When a user submits a job with cron, their environment is not
     1525 preserved. This is reasonable since cron jobs are typically ongoing
     1526 and may be adversely affected if the user's environment changes subsequent
     1527 to the cron submission. Thus, a cron job should call a script that
     1528 set's up the correct environment before starting the user's desired
     1529 program. The 'at' command does this nicely.
     1530 </para>
     1531 </sect2>
     1532 <sect2><title>Interactivity</title>
     1533<para>
     1534When a job is started with cron, it runs as a background process.
     1535 No interaction with the program is possible (unless it is capable
     1536 of interacting via a FIFO or some such) except termination via its
     1537 pid. The only program that I know of that allows such interaction
     1538 and serves as a wrapper for other prrocesses is 'screen'
     1539 </para>
     1540 </sect2>
     1541 <sect2><title>Screen</title>
     1542<para>
     1543There's one little problem with screen though. It expects to
     1544 attach to a terminal when it first starts. This won't happen under
     1545 cron so screen will fail. Fortunately, screen comes with a "start
     1546 detached" option.
     1547 </para>
     1548 </sect2>
     1549 </sect1>
     1550 <sect1 id="backup-cron-solution">
     1551         <title>The Solution</title>
     1552<sect2><title>Briefly</title>
     1553<para>
     1554<itemizedlist>
     1555<listitem>
     1556        <para>Use 'at' to run your usual mondoarchive command</para>
     1557</listitem>
     1558<listitem>
     1559        <para>Grab the script generated by 'at' and make a copy of it</para>
     1560        </listitem>
     1561<listitem>
     1562        <para>Edit that script to use 'screen -m -d &lt;your mondoarchive command&gt;'</para>
     1563        </listitem>
     1564<listitem>
     1565        <para>Run that script from your crontab</para>
     1566        </listitem>
     1567<listitem>
     1568        <para>Use 'screen -r' to attach to the mondo screen to change CDs</para>
     1569        </listitem>
     1570<listitem>
     1571        <para>Use '&lt;CTRL&gt;-a d' to detach the screen again</para>
     1572</listitem>
     1573</itemizedlist>
     1574</para>
     1575</sect2>
     1576<sect2><title>In Detail</title>
     1577        <sect3><title>at</title>
     1578<para>
     1579Use the 'at' command to submit your usual mondoarchive command.
     1580My mondoarchive command is:
     1581</para>
     1582<informaltable><tgroup cols="1"><tbody>
     1583<row>
     1584<entry>
     1585
     1586    # mondoarchive -D -Ow 10 -S /home/mondo/ -T /home/mondo/ -g &bsol;
     1587-E &quot;&bsol;&quot;/home/cdaly/GIS/W2K /home/mondo/&bsol;&quot;&quot; -9
     1588
     1589</entry>
     1590</row>
     1591</tbody></tgroup></informaltable>
     1592<para>
     1593        To submit the mondoarchive command with 'at' do:
     1594</para>
     1595<informaltable><tgroup cols="1"><tbody>
     1596<row>
     1597<entry>
     1598
     1599    # at now + 5 min
     1600mondoarchive -D -Ow 10 -S /home/mondo/ -T /home/mondo/ -g &bsol;
     1601-E &quot;&bsol;&quot;/home/cdaly/GIS/W2K /home/mondo/&bsol;&quot;&quot; -9
     1602&lt;CTRL&gt;-d
     1603</entry>
     1604</row>
     1605</tbody></tgroup></informaltable>
     1606<para>
     1607
     1608This generates a script in /var/spool/at/ which sets up your
     1609 environment and runs your command. Grab this script to become your
     1610 cron job.
     1611 </para>
     1612 </sect3>
     1613 <sect3><title>Grab the 'at' script</title>
     1614<para>
     1615        Make a copy of the script generated by the 'at' command to use
     1616        as the basis for your cron job.
     1617        </para>
     1618<informaltable><tgroup cols="1"><tbody>
     1619<row>
     1620<entry>
     1621
     1622grep mondo /var/spool/at/*
     1623</entry>
     1624</row>
     1625<row>
     1626        <entry>
     1627cp /var/spool/at/&lt;file-from-grep&gt; /root/mondo-cronscript
     1628</entry>
     1629</row>
     1630</tbody></tgroup></informaltable>
     1631<para>
     1632
     1633        You'll need to edit this.
     1634</para>
     1635 </sect3>
     1636<sect3><title>Edit mondo-cronscript</title>
     1637<para>
     1638To use screen, you'll need to edit the cronscript and add the
     1639 screen command. My mondo-cronscript looks like:
     1640</para>
     1641<screen>
     1642
     1643#!/bin/sh
     1644# atrun uid=0 gid=0
     1645# mail    cdaly 0 umask 22
     1646PWD=/root; export PWD
     1647XAUTHORITY=/root/.xauthyOrD4f; export XAUTHORITY
     1648HOSTNAME=bofh.irmet.ie; export HOSTNAME
     1649PVM_RSH=/usr/bin/rsh; export PVM_RSH
     1650QTDIR=/usr/lib/qt-2.3.1; export QTDIR
     1651LESSOPEN=\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN
     1652XPVM_ROOT=/usr/share/pvm3/xpvm; export XPVM_ROOT
     1653KDEDIR=/usr; export KDEDIR
     1654USER=root; export USER
     1655LS_COLORS=no=00:fi=00:di=01\;34:ln=01\;36:pi=40\;33:so=01\;35:bd=40\;33\;01:cd=40\;33\;01:or=01\;05\;37\;41:mi=01\;05\;37\;41:ex=01\;32:\*.cmd=01\;32:\*.exe=01\;32:\*.com=01\;32:\*.btm=01\;32:\*.bat=01\;32:\*.sh=01\;32:\*.csh=01\;32:\*.tar=01\;31:\*.tgz=01\;31:\*.arj=01\;31:\*.taz=01\;31:\*.lzh=01\;31:\*.zip=01\;31:\*.z=01\;31:\*.Z=01\;31:\*.gz=01\;31:\*.bz2=01\;31:\*.bz=01\;31:\*.tz=01\;31:\*.rpm=01\;31:\*.cpio=01\;31:\*.jpg=01\;35:\*.gif=01\;35:\*.bmp=01\;35:\*.xbm=01\;35:\*.xpm=01\;35:\*.png=01\;35:\*.tif=01\;35:; export LS_COLORS
     1656MACHTYPE=i386-redhat-linux-gnu; export MACHTYPE
     1657MAIL=/var/spool/mail/root; export MAIL
     1658INPUTRC=/etc/inputrc; export INPUTRC
     1659BASH_ENV=/root/.bashrc; export BASH_ENV
     1660LANG=en_US; export LANG
     1661LOGNAME=root; export LOGNAME
     1662SHLVL=1; export SHLVL
     1663II_SYSTEM=/usr/local/ingres; export II_SYSTEM
     1664USERNAME=root; export USERNAME
     1665HOSTTYPE=i386; export HOSTTYPE
     1666OSTYPE=linux-gnu; export OSTYPE
     1667HISTSIZE=1000; export HISTSIZE
     1668LAMHELPFILE=/etc/lam/lam-helpfile; export LAMHELPFILE
     1669PVM_ROOT=/usr/share/pvm3; export PVM_ROOT
     1670HOME=/root; export HOME
     1671SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass;
     1672export SSH_ASKPASS
     1673PATH=/usr/local/ingres/ingres/bin:/usr/local/ingres/ingres/utility:/usr/kerberos/sbin:/usr/kerberos/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin; export PATH
     1674cd /root || {
     1675echo 'Execution directory inaccessible' >&2     
     1676exit 1
     1677}
     1678screen -m -d mondoarchive -D -Ow 10 -S /home/mondo/ -T \
     1679/home/mondo/ -g -E "\"/home/cdaly/GIS/W2K /home/mondo/\"" -9
     1680#done
     1681
     1682</screen>
     1683<para>
     1684        The crucial line is this one:
     1685</para>
     1686<informaltable><tgroup cols="1"><tbody>
     1687<row>
     1688<entry>
     1689        screen -m -d mondoarchive -D -Ow 10 -S /home/mondo/ -T &bsol;
     1690/home/mondo/ -g -E &quot;&bsol;&quot;/home/cdaly/GIS/W2K /home/mondo/&bsol;&quot;&quot; -9
     1691</entry>
     1692</row>
     1693</tbody></tgroup></informaltable>
     1694<para>
     1695This uses 'screen -m -d' to <quote>-m -d Start screen in "detached" mode. This creates a new session
     1696 but doesn't attach to it. This is useful for system startup scripts.
     1697 (From 'man screen')
     1698</quote>   
     1699</para>
     1700<para>
     1701    When screen starts, it will be in the background and "detached".
     1702</para>
     1703</sect3>
     1704<sect3><title>Run the thing with cron</title>
     1705<para>
     1706        To get the whole thing running, do:
     1707</para>
     1708<informaltable><tgroup cols="1"><tbody>
     1709<row>
     1710<entry>
     1711        crontab -e
     1712        </entry>
     1713</row>
     1714</tbody></tgroup></informaltable>
     1715<para>
     1716and add the following lines:
     1717</para>
     1718<informaltable><tgroup cols="1"><tbody>
     1719<row>
     1720<entry>
     1721&num; run mondoarchive at 23:59 weekdays
     1722</entry>
     1723</row>
     1724<row>
     1725        <entry>
     172659 23 * * 1-5 /root/mondo-cronscript
     1727</entry>
     1728</row>
     1729</tbody></tgroup></informaltable>
     1730<para>
     1731        Your mondoarchive job will run at 23:59 monday-friday.
     1732</para>
     1733<para>
     1734DON'T FORGET TO CHANGE TAPES!
     1735</para>
     1736</sect3>
     1737<sect3><title>Getting at it...</title>
     1738<para>
     1739Once your cron job is running regularly, you'll want to get to
     1740 it to change tapes and check status etc.
     1741</para>
     1742<informaltable><tgroup cols="1"><tbody>
     1743<row>
     1744<entry>
     1745screen -r
     1746</entry>
     1747</row>
     1748</tbody></tgroup></informaltable>
     1749<para>
     1750attaches to the running screen where you can change CDs etc
     1751</para>
     1752<informaltable><tgroup cols="1"><tbody>
     1753<row>
     1754<entry>
     1755&lt;CTRL&gt;-a d
     1756</entry>
     1757</row>
     1758</tbody></tgroup></informaltable>
     1759<para>
     1760detaches the running screen again.
     1761</para>
     1762</sect3>
     1763<sect3><title>Caveat</title>
     1764<para>
     1765The script generated by 'at' is unique to the user/machine combination.
     1766 You MUST regenerate it on each machine where it will be used. Using
     1767 the one above will NOT work for you. MAKE YOUR OWN!
     1768</para>
     1769</sect3>
    13761770</sect2>
    13771771</sect1>
     
    15031897<row>
    15041898<entry>
    1505 
    15061899        bash# mount-me
     1900</entry>
     1901</row>
     1902<row>
     1903<entry>
    15071904        bash# chroot /mnt/RESTORING
    1508         bash# lilo OR grub-install '(hd0)'
    1509         bash# exit
     1905        </entry>
     1906</row>
     1907<row>
     1908<entry>
     1909        </entry>
     1910</row>
     1911<row>
     1912<entry>
     1913bash# lilo OR grub-install '(hd0)'
     1914        </entry>
     1915</row>
     1916<row>
     1917<entry>
     1918bash# exit
     1919</entry>
     1920</row>
     1921<row>
     1922<entry>
    15101923        bash# unmount-me
    15111924
     
    16162029
    16172030        Do you want to partition your devices? no
    1618         Do you want to format them? no
    1619         Do you want to restore everything? no
    1620         Do you want to restore something? yes
    1621         Which path do you want to restore? /mydata [e.g.]
    1622         Do you want to run LILO to setup your boot sectors? Yes
     2031        </entry>
     2032</row>
     2033<row>
     2034<entry>
     2035Do you want to format them? no
     2036        </entry>
     2037</row>
     2038<row>
     2039<entry>
     2040Do you want to restore everything? no
     2041        </entry>
     2042</row>
     2043<row>
     2044<entry>
     2045Do you want to restore something? yes
     2046        </entry>
     2047</row>
     2048<row>
     2049<entry>
     2050Which path do you want to restore? /mydata [e.g.]
     2051        </entry>
     2052</row>
     2053<row>
     2054<entry>
     2055Do you want to run LILO to setup your boot sectors? Yes
    16232056
    16242057</entry>
     
    17232156
    17242157        /dev/hda1   /mnt/windows    vfat        4096000
     2158</entry>
     2159</row>
     2160<row>
     2161<entry>
    17252162        /dev/hda5   /               reiserfs    6023000
     2163</entry>
     2164</row>
     2165<row>
     2166<entry>
    17262167        /dev/hda6   /tmp            xfs         955000
     2168</entry>
     2169</row>
     2170<row>
     2171<entry>
    17272172        /dev/hda7   /usr            ext3        4096000
    17282173
     
    17532198
    17542199        /dev/hda1   /mnt/windows    vfat        6096000
     2200</entry>
     2201</row>
     2202<row>
     2203<entry>
    17552204        /dev/hda5   /               reiserfs    9123000
     2205</entry>
     2206</row>
     2207<row>
     2208<entry>
    17562209        /dev/hda6   /tmp            xfs         955000
     2210</entry>
     2211</row>
     2212<row>
     2213<entry>
    17572214        /dev/hdb1   /usr            ext3        8192000
     2215</entry>
     2216</row>
     2217<row>
     2218<entry>
    17582219        /dev/hdb2   /home           xfs         8192000
    17592220
     
    17732234
    17742235        /dev/hda1   /mnt/windows    vfat        6096000
     2236</entry>
     2237</row>
     2238<row>
     2239<entry>
    17752240        /dev/md0    /               reiserfs    9123000
     2241</entry>
     2242</row>
     2243<row>
     2244<entry>
    17762245        /dev/md1    /tmp            xfs         955000
     2246</entry>
     2247</row>
     2248<row>
     2249<entry>
    17772250        /dev/md2    /usr            ext3        8192000
     2251</entry>
     2252</row>
     2253<row>
     2254<entry>
    17782255        /dev/md3    /home           xfs         8192000
    17792256
     
    22892766<entry>
    22902767        Put an empty Boot floppy
     2768</entry>
     2769</row>
     2770<row>
     2771<entry>
    22912772        bash# fdformat /dev/fd0u1722
     2773</entry>
     2774</row>
     2775<row>
     2776<entry>
    22922777        bash# dd if=/root/images/mindi/mindi-boot.1722.img of=/dev/fd0u1722
     2778</entry>
     2779</row>
     2780<row>
     2781<entry>
    22932782        Put an empty Data floppy
     2783</entry>
     2784</row>
     2785<row>
     2786<entry>
    22942787        bash# fdformat /dev/fd0
     2788</entry>
     2789</row>
     2790<row>
     2791<entry>
    22952792        bash# dd if=/root/images/mindi/mindi-data-N.img of=/dev/fd0
     2793</entry>
     2794</row>
     2795<row>
     2796<entry>
    22962797        Replace N with 1, 2, etc.
    22972798
     
    24142915
    24152916        bash# cd /mnt/cdrom/images
     2917</entry>
     2918</row>
     2919<row>
     2920<entry>
    24162921        bash# dd if=mindi-boot.1722.img of=/dev/fd0u1722
    24172922
Note: See TracChangeset for help on using the changeset viewer.