home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / massive-backup.el < prev    next >
Encoding:
Text File  |  1992-07-05  |  3.4 KB  |  102 lines

  1. ;;;
  2. ;;; LCD Archive Entry:
  3. ;;; massive-backup|Terry Brannon|brannon@jove.cs.caltech.edu|
  4. ;;; Automatically tar and copy directories to remote machines|
  5. ;;; 92-07-04|1.00|~/misc/massive-backup.el.Z|
  6. ;;; 
  7. ;;; Description
  8. ;;; massive-backup.el allows one to specify directories to be tarred,
  9. ;;; compressed and copied to a another location. The remote 
  10. ;;; location may be specified as an ange-ftp pathname. The local
  11. ;;; location is specified as a Un*x relative or absolute pathname.
  12. ;;; 
  13. ;;; Requirements
  14. ;;; Ange-ftp, obtainable from "/anonymous@alpha.gnu.ai.mit.edu:/ange-ftp"
  15. ;;;
  16. ;;; Use and Installation
  17. ;;;
  18. ;;; - Set the car of the variable massive-backup-list to the the local
  19. ;;;   directories to be tarred and compressed. Set the cdr to a list of
  20. ;;;   remote destination directories. The cdr must be a list even if you
  21. ;;;   only have one remote destination.
  22. ;;;
  23. ;;; - In your .emacs file somewhere after declaring your load-path
  24. ;;;   variable, insert the following line:
  25. ;;;   (autoload 'massive-backup "massive-backup" "" t)
  26. ;;;
  27. ;;; - Place this file somewhere on your load-path
  28. ;;;
  29. ;;; - Invoke by type M-x massive-backup
  30. ;;;
  31.  
  32. ;;; Configurable Variable Defines
  33.  
  34. (defvar default-destination-list
  35.   '(
  36.     "/tb06@pl122b:/scratch/china.primitive/Thesis/"
  37.     "/brannon@jove.cs.caltech.edu:Thesis/"
  38.     "/tb06@ns1.cc.lehigh.edu:Thesis/")
  39. "This is just for my bookkeeping . I had to manually insert this list
  40. below because I could not get the list to evaluate itself")
  41.  
  42. (defvar massive-backup-list 
  43.   '(
  44.     ("~/Thesis/src"        
  45.      .     ( "/tb06@pl122b:/scratch/china.primitive/Thesis/"
  46.          "/brannon@jove.cs.caltech.edu:Thesis/"
  47.          "/tb06@ns1.cc.lehigh.edu:Thesis/" ))
  48.  
  49. ;    ("~/repository"        
  50. ;     .     ( "/tb06@pl122b:/scratch/china.primitive/Thesis/"
  51. ;         "/brannon@jove.cs.caltech.edu:Thesis/"
  52. ;         "/tb06@ns1.cc.lehigh.edu:Thesis/" ))
  53.  
  54.     ("~/Thesis/examples"        
  55.      .     ( "/tb06@pl122b:/scratch/china.primitive/Thesis/"
  56.          "/brannon@jove.cs.caltech.edu:Thesis/"
  57.          "/tb06@ns1.cc.lehigh.edu:Thesis/" ))
  58.  
  59. ;    ("~/Thesis/latex"        
  60. ;     .     ( "/tb06@pl122b:/scratch/china.primitive/Thesis/"
  61. ;         "/brannon@jove.cs.caltech.edu:Thesis/"
  62. ;         "/tb06@ns1.cc.lehigh.edu:Thesis/" ))
  63.     )
  64. "Absolute pathnames to the directories to be backed up. In this
  65. default case, each tar file is sent to the same place. Feel free to
  66. configure your own destination lists... they must be lists even if you
  67. only have one destination")
  68.  
  69. ;;;
  70. ;;; Source code . No need for alteration
  71. ;;;
  72.  
  73. (require 'ange-ftp)
  74. (setq debug-on-error t)
  75.  
  76. (defun massive-backup()
  77.   (interactive)
  78.   (mapcar '(lambda (x) 
  79.          (backup (car x))) massive-backup-list)
  80.   (message "Massive backup completed. Breathe a sigh of relief."))
  81.  
  82. (defun backup (filename)
  83.   (let ((DIR (file-name-directory (expand-file-name filename)))
  84.     (FILE (file-name-nondirectory (expand-file-name filename))))
  85.  
  86.     (my-shell-command (concat "cd " DIR " ;  \\rm "  DIR FILE ".tar*"))
  87.     (my-shell-command (concat "cd " DIR " ; tar cvf " FILE ".tar " FILE))
  88.     (my-shell-command (concat "cd " DIR " ; compress " FILE ".tar"))
  89.  
  90.     (let ((dest (cdr (assoc filename massive-backup-list))))
  91.       (mapcar '(lambda (x)
  92.          (copy-file (concat DIR FILE ".tar.Z")
  93.                 (concat x FILE ".tar.Z") t))
  94.           dest))
  95.  
  96.     (my-shell-command (concat "\\rm " DIR FILE ".tar.Z"))))
  97.  
  98. (defun my-shell-command (exec-string)
  99.   (message (concat "[Action]: " exec-string)) 
  100.   (shell-command exec-string))
  101.  
  102.