Douglas A. Tutty <dtu...@vianet.ca>: > On Fri, Mar 13, 2009 at 11:00:58AM -0500, Boyd Stephen Smith Jr. wrote: > > On Friday 13 March 2009 08:43:07 Douglas A. Tutty wrote: > > > As for rolling upgrades, great but what about when e.g. a hard > > drive > > > fails. > > > > It's called a "backup". > > Sure, if you want to do a back-up of the whole installed she-bang > (rather than just the data and the required debs).
I use the following to do backups. It calls afio using bzip compression to back up specific filesystems (/home, /etc, /var, ...). It does not bother to backup anything that's on a Debian install CD. Install minimal Debian on new box, drag in your archives, and you're back to square one. You do not need to "image the drive" a la Windows. The Debian installer is much better at sorting that stuff out than you or I. Caveat, relies on a /scratch hierarchy. ----------------------------- #!/bin/bash # # /home/keeling/sh/new_mkafio - usage (as of Etch (16Nov2007)): # # i) Build compressed afio archives of selected partitions. # # (0) heretic /home/keeling_ su -c \ # "time nice ~keeling/sh/mkafio" # # ii) Manually copy any other files you want archived into # ${AFIO} (defined in root's .profile). # # iii) burn the result to CD-R(W): # # *** New! *** mkisofs is done by function mkiso. # **** Newer! Disabled! Run mkisofs as follows. # ***** Newer! Yes, and what does that mean? Why is mkiso() deprecated? Idiot! # ****** Where is "${ISO} today? Does root know? He's running this. # ******* mkiso() is re-enabled, and it works on phreaque/Etch. # # *** Don't do this! The script does it for you. *** # (0) heretic /home/keeling_ mkisofs -o $ISO/track_01.img \ # -pad -allow-leading-dots -max-iso9660-filenames \ # -r -relaxed-filenames $AFIO # # (0) heretic /home/keeling_ wodim speed=16 dev=/dev/hdd fs=64M \ # -eject -data driveropts=burnfree $ISO/track_01.img # # afio switches: -z print stats # -Z compress # -v verbose # -T 3k files < 3 Kb are not compressed # (for performance) # -o output filename # -P bzip2 use bzip2 compression # # Documentation: see EOF. # # ------------------------------------------------------------- # # set -x # who should everything end up being owned by? # owner=keeling ogroup=keeling umask 022 # was 0022; testing - 24Jan2008 # paranoia. # if [ -f "~/mkafio_fail" ]; then echo failed last time. \$HOME/mkafio_fail exists. exit 0 fi # some defaults # if [ -d /scratch ]; then topdir=/scratch elif [ -d /home/keeling/scratch ]; then topdir=/home/keeling/scratch else echo Cannot determine whereabouts of \$scratch; bailing. # initialize paranoia. # touch ~/mkafio_fail exit 1 fi workdir=${topdir}/afio iso=${topdir}/iso/track_01.img me=$(basename ${0}) now=$(date '+%Y%m%d') mo=$(date '+%m') # backup the old one, copy in the new one, before we burn backup. # mv ${workdir}/mkafio ${workdir}/mkafio_old cp /home/keeling/sh/mkafio ${workdir} # DON'T put "${AFIO}" in here! It's where everything else # is written to. Contents of ${topdir}/afio WILL be # burned to the iso by mkisofs # ptns="etc home var" # ------------------------------------------------------------ # Functions. - # ------------------------------------------------------------ # mkisofs? create iso fs for wodim to burn. # mkiso() { genisoimage -o ${iso} \ -allow-leading-dots -pad -max-iso9660-filenames \ -input-charset iso-8859-15 -r -relaxed-filenames \ -T -publisher 's. keeling <keel...@nucleus.com>' \ ${workdir} sleep 10 chown keeling:keeling ${iso} } # tar up /root # root() { echo "${me}: archiving root's HOME." tar czpf ${workdir}/${now}_root.tgz /root sleep 3 # chmod 660 ${workdir}/${now}_root.tgz chown keeling:keeling ${workdir}/${now}_root.tgz } # tar up /usr/local # uloc() { echo "${me}: /usr/local" tar czpf ${workdir}/${now}_usrlocal.tgz /usr/local } # create list of installed packages. # plist() { if [ -f "/etc/debian_version" ]; then echo "${me}: making sorted package list." /usr/bin/dpkg --get-selections > ${workdir}/${now}_packages.txt else echo "${me}: not running Debian. Cannot make pkg list!" echo 'see plist()' fi } # list ptn config. # ptns() { echo "${me}: creating fdisk listing." fdisk -l > ${workdir}/${now}_fdisk.txt echo "" >> ${workdir}/${now}_fdisk.txt pydf --bw -h >> ${workdir}/${now}_fdisk.txt } # list pci devices. # ls_pci() { echo "${me}: saving lspci output." lspci -vv > ${workdir}/${now}_lspci.txt } # raw hardware listing. # "hwinfo --short", too expensive and disruptive (don't trust). # I have a copy run in 23Mar2008. no need for it again. # hw_info() { for target in lsmod dmesg; do echo "${me}: saving ${target} output." ${target} > ${workdir}/${now}_${target}.txt done } # list /scratch/afio # a_dir() { echo "${me}: making afio dir listing." ls -alF ${topdir}/afio > ${workdir}/${now}_scratchafiols.txt } # compress logs. # zippem() { echo "${me}: compressing logs and text files." bzip2 -f *.log bzip2 -f *.txt } # hammer ownerships # owns() { echo "${me}: changing ownerships." for f in ${workdir}/*; do chown ${owner}:${ogroup} ${f} done } # this routine isn't called. another/different "compress # logs"/zippem(). redundant? # # wrong too. this syntax should loop. better to use zippem's # globbing. # logzip() { echo "${me}: compressing log files." bzip2 -f ${workdir}/${now}_${pkg}.log } # end functions. # ------------------------------------------------------------ # # must be run as root! it's backing up the system, including # user and root areas. it needs unfettered access. # if [ ${UID} = 0 ]; then echo "${me}: starting at $(date)" if [ -f "${iso}" ]; then echo "${me}: deleting obsolete iso." rm -f ${iso} fi cd ${workdir} if [ "${#}x" = "0x" ]; then echo "${me}: moving old archives out of the way." rm -f ${topdir}/old_afio/* mv ${workdir}/200[0-9]* ${topdir}/old_afio/ for f in ${ptns}; do if [ -f "${workdir}/tarX_${f}" ]; then echo "${me}: creating ${workdir}/${now}_${f}.afio" # this ptn has a tarX_ file # find /${f} | \ egrep -v "`cat ${workdir}/tarX_${f}`" | \ afio -z -Z -P bzip2 -v -T 3k \ -o ${workdir}/${now}_${f}.afio \ > ${workdir}/${now}_${f}.log 2>&1 else echo "${me}: creating ${workdir}/${now}_${f}.afio" # this ptn does not have a tarX_ file # find /${f} | \ egrep -v "^/proc|lost\+found" | \ afio -z -Z -P bzip2 -v -T 3k \ -o ${workdir}/${now}_${f}.afio \ > ${workdir}/${now}_${f}.log 2>&1 fi done # can't loop this; 'slash' != '/' # root plist ptns uloc ls_pci # brutal command. skipped for now. not installed? correct. # # wrong. this doesn't use hwinfo. it's a func which calls # shell tools. # hw_info a_dir zippem owns mkiso elif [ "${1}x" != "x"]; then # invoked as "mkafio blah", so only create afio archive for # /blah filesystem, either using or not using tarX_blah # exclude file. # pkg="${1}" for f in ${workdir}/*_${pkg}.*; do echo "${me}: removing ${f}" rm -f ${f} done echo "${me}: creating ${workdir}/${now}_${pkg}.afio" if [ -f "${workdir}/tarX_${pkg}" ]; then find /${pkg} | \ egrep -v "`cat ${workdir}/tarX_${pkg}`" | \ afio -z -Z -P bzip2 -v -T 3k \ -o ${workdir}/${now}_${pkg}.afio \ > ${workdir}/${now}_${pkg}.log 2>&1 else find /${pkg} | \ egrep -v "^/proc|lost\+found" | \ afio -z -Z -P bzip2 -v -T 3k \ -o ${workdir}/${now}_${pkg}.afio \ > ${workdir}/${now}_${pkg}.log 2>&1 fi zippem echo "${me}: changing ownerships." # chmod 660 ${workdir}/${now}_${pkg}.* chown ${owner}:${ogroup} ${workdir}/${now}_${pkg}.* fi else echo "${me}: This must be run by root." exit 1 fi # $UID = 0 # set +x # !!! Historical !!! # # Theory: # Sometimes I run this to create a full backup, and sometimes # I run it to create an update to an older backup (usually just # my /home directory). It's also useful for when you've # forgotten to mount /boot prior to archiving (formerly, my /boot # was left unmounted). # # Usage: # - List partitions to be backed up in "${ptns}". # - Copy anything else to be backed up to "${workdir}". # - Anything NOT to be backed up, list in "tarX_blah" file. # - Run it: # time nice --adjustment=20 makeafio # or: # makeafio [PTN] # # where "[PTN]" is none or one of those listed in "${ptns}". # # This script creates afio archives in my ${topdir}/afio directory. # Once completed, use mkisofs or XCDRoast/KonCD/k3b/... to create a # ".img" file, then burn the contents of ${topdir}/iso to CD. # Everything in ${topdir}/afio will go into the ".img" file, so for # anything beyond the afio archives you want to end up on the # CD, copy that into ${topdir}/afio before running this. # ------------------------------------------------------------- # # Usage details: # - This needs to run as root to do anything. # - Assign the partitions you want backed up in ${ptns} # - Everything else you want backed up should go in ${workdir} # (here, ${topdir}/afio). Anything you don't want in the afio # archives should be listed in a "tarX_PTN" file. Ie., if you # don't want /blah backed up, add "|^/blah" to the slash (root) # partition's tarX_slash file thus: # # "^/proc|lost\+found|whatever|^/blah" # # This should be a single line file. It forms an exclude list # for the egrep pipe. If your partitions aren't split up quite so # much as mine, you may have to augment your tarX_* files # considerably. The default exclude list contains "^/proc|lost\+found", # knowing these two should never be backed up for any reason. # # - To burn the result to CD-R(W): # # (use "wodim --devices" (on Debian) to find yours). # # - As soon as the ${topdir}/iso/track_01.img file has been burned to # CD, the .img file can be removed to recover space (done by makeafio # when it starts). # # - To recover data from an afio archive, SET DEFAULT TO THE DIR # TO WHICH YOU WISH THE DATA WRITTEN[*] ("cd ~/dwn"), then (assuming # the input's on CD, mounted on /cdrom): # # afio -Z -P bzip2 -v -i /cdrom/name_of_afio_archive # # [*] Had you set def to ~keeling/dwn, you would now have the # contents written in ~keeling/dwn/path/to/... # # HOWEVER, had you been in directory "/", you will have REPLACED # your "afio_archive" (/home, /etc, /, ...)directory. This may # be a good or bad thing depending upon your circumstances. This # is comparable to the way Gnu tar works; afio strips off leading # "/" chars on filenames just like Gnu tar, so the restore will # be written to the user's $PWD. # # To recover a _single file_ from an afio archive: # # afio -Z -P bzip2 -v -i -y path/to/single/file.txt /cdrom/afio_archive # # - Test the contents of an afio archive with: # # afio -tZ -P bzip2 /full/path/to/afio_archive # # New; to recover Debian: # dpkg --get-selections > /mnt/${now}_packages.txt # dpkg --set-selections < /mnt/${now}_packages.txt # aptitude update # aptitude install # # ?????2001 sbk. 0001 begin. # 20Feb2002 sbk. 0002 added progress reporting comments. # 2Apr2002 sbk. 0003 convert to afio. # 3Apr2002 sbk. 0004 renumbered. works. maintain. # 3Apr2002 sbk. 0005 version creep. # 6May2002 sbk. 0006 start time, single archive. # 30May2002 sbk. 0007 minimal reformatting (comments). # 4Jun2002 sbk. 0007 more comments. # 19Jan2003 sbk. 0008 ${workdir}/${now}_scratchafiols.txt # 17Mar2004 sbk. 0009 if [ ${mo} = 01 ] # 7Apr2004 sbk. 0010 dpkg --get-selections # 8Apr2004 sbk. 0011 /scratch/iso/track_01.img # 14May2004 sbk. 0012 fixed some comments. # 11Jul2004 sbk. 0013 fixed some more comments. # 21Jul2004 sbk. 0014 added more comments. # 12Oct2004 sbk. 0015 disabled ${blast}, simplified cleanup. # 20Oct2004 sbk. 0016 find ... -print0 # 29Oct2004 sbk. 0017 backed out "find ... -print0" # 29Apr2005 sbk. 0018 comments. # 15Aug2005 sbk. 0019 no /boot anymore. # 14Sep2005 sbk. 0020 dev=ATAPI:0,0,0 # 8Nov2005 sbk. 0021 2.6 kernel, dev=0,0,0 # 4Mar2006 sbk. 0022 2.6 kernel, sarge, dev=/dev/hdc # 27Jun2006 sbk. 0023 2.6 kernel, sarge, dev=/dev/hdd # 11Feb2007 sbk. 0024 bzip2 # 9Jun2007 sbk. 0025 Etch. no more /scratch. # 24Jan2008 sbk. 0026 Etch. P-IV update, wodim. # 23Mar2008 sbk. 0027 Many functions, much clean up. # ----------------------------------------------------------------- # # Notes (based on wl's testing). Need to update with rip # commands (dd?): # # - Try: # # cdrecord dev=/dev/hdd -useinfo -audio image.iso # # - To erase CD-RW (almost failed on *buntu?): # # cdrecord blank=all dev=/dev/hdd # # - cdrdao fails portability: # # cdrdao copy --device /dev/hdd --eject --reload # # - cdparanoia fails portability: # # cdparanoia -B -- "-14" # <-- no. of tracks # cdrecord dev=/dev/hdd -audio -pad *.wav # # Output, using bzip2: # ----------------------------- -- Any technology distinguishable from magic is insufficiently advanced. (*) http://www.xs4all.nl/~js/gnksa/ Linux Counter #80292 - - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org