sandy on 12 Mar 2005 15:39:57 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] cdrecord backups that are very reliable


sometime ago there was an e-mail discussion about cd backups.
I have worked on making cd backups for our new machine for the business.
I am enclosing an e-mail that I sent to the the person that wrote
the CD-WRITTING_HOWTO.

 I would like to thank you for CD-Writing-HOWTO.
 It is a very useful document and was greatly appreciated.

 There is, however one flaw in the write up that I would like
 to see changed so others will not struggle as I have.  I spent
  a long  time trying to  get bru and afio do effective CD backups
 
At the end of your excellent CD-Writing-HOWTO  in section 4.27 you state

"4.27   What will cdrecord do when it stops getting input from the
         pipe?"
	 
	This statement should  be removed.
	  One cannot pipe  to cdrecord and make a working backup.
	  
	 It does not work for bru or afio.   It cannot retrieve  the
	 tail files in the backup because of the linux read ahead feature.
	 To backup to a CD ROM, one must first form the whole backup
	 under /tmp or some other temporary  area.
	 Now check to make sure that the file will fit on the CD (an
	 added bonus)
	 Then do mkisofs and cdrecord
	 
	 Next  following the advice given by
	 Mr Steve Litt in "Coasterless CD Burning"
	    presented by Troubleshooters.com and T.C Linux Library
         One must md5sum the archive formed by cdrecord in memory 
	       md5sum /tmp/cd_image
	  and md5sum the /CD R or CD RW archive. 
	        md5sum /cdrom/afio.arch
      
      I have  had cdrecord state that the CDR was successfully written.	
      I then
           md5sum /cdrom/afio.arch.  md5sum reported multiple I/O
	   failures  reading the archive.
	   The CD write had failed. The afio archive was on a CDRW disk.
	I blanked the disk and reran my script.  The second time was successful.
     
      
    Enclosed  are 3 scripts that I wrote to do the backup.

   #1)  file daily  .. the master script

           #!/bin/sh
	  date > /tmp/start_time
	  
	  # cd_file_find  reads a file containing all of the desired
	  #   directories ,one directory per line.

          # cd_file_find forms a file,/tmp/cd_files, containing all the files to
	  # back up.  

              /home/vm/cd/cd_file_find /home/vm/cd/daily_directories
          # cdrom_backup forms the afio file,/tmp/afio.arch, and records to CDR

             /home/vm/cd/cdrom_backup 

            echo "end   "   `date`
           echo -n "start "  
          cat /tmp/start_time

#2)cd_file_find  file listing directories desired: one directory /line

    #!/bin/sh
     #   program used to produce a list of files in all  directories
     #      listed in the file $1
     if [ $# -eq 0 ]
        then
       echo " need a file of directories"
       exit 1

    fi
  
   rm /tmp/cd_files
   for i in `cat $1`
    do
     find $i  >>/tmp/cd_files
   done

#3 cdrom_backup   
#!/bin/sh
#  cdrom_backup   ............takes the files stored in /tmp/cd_files
#                 ............ forms an afio archive....
#                               checks that the afio operation was successful
#                               checks that the afio archive is < 650m bytes
#             ........  writes the afio archive to a cdrom image,/tmp/cd_image
#                   .......... cdrecords the file and checks the md5sum


#   backup log is in /home/cd_backup_log... the last log is appended to the
#     file

cat /tmp/cd_files | afio -o -T 3k -L  /home/backup/cd_backup_log -Z -P bzip2 \
     /tmp/afio.arch
     
#check that afio was successful
tail -1 /home/backup/cd_backup_log  | grep successful 
es=$?
#echo "$es"  es
if [ $? -ne 0 ]
   then
   echo "afio failed"
   exit 1
   fi

# check that the afio archive  will fit on the CD
tail -2 /home/backup/cd_backup_log   | grep afio >/tmp/checks
cut -d" " -f4 /tmp/checks | cut -d"m" -f1 | cat >/tmp/checks
declare -i a
read a </tmp/checks
echo "$a" backup size

if [ $a -gt 650 ]
   then
   echo  backup files are to big at "$a" 
   echo  backup files are to big at "$a" >>/home/backup/cd_backup_log 
   
   exit 1
   fi

mkisofs -r -o /tmp/cd_image /tmp/afio.arch

cdrecord dev=1,0,0 speed=5 -v -pad  /tmp/cd_image

md5sum /tmp/afio.arch  | cut -d" " -f1 >/tmp/atmp
c=`cat /tmp/atmp`
echo "$c"
  mount /cdrom
      md5sum /cdrom/afio.arch | cut -d" " -f1 >/tmp/atmp1
      b=`cat /tmp/atmp1`
   umount /cdrom
echo "$b"
if [ "$c" != "$b" ]
   then
   echo " bad cdrom write"
   echo " bad cdrom write"  >>/home/backup/cd_backup_log 
   exit 1
   else
   echo " successful cdrom write" 
   echo " successful cdrom write"  >>/home/backup/cd_backup_log 
   fi

 date
exit 0


##########
again, thank you for taking the time to write CD-Writing-HOWTO.
truly,
sandy basickes    s_basic@verizon.net

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug