This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 25th, 2013  |  syntax: Bash  |  size: 1.34 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          memdisksync
  4. # Required-Start:    $remote_fs $syslog
  5. # Required-Stop:     $remote_fs $syslog
  6. # X-Start-Before:    mysql
  7. # X-Start-After:     mysql
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Load Syncing memdisk and backup
  11. # Description:       Syncs memdisk and backup at startup and set intervals.
  12. ### END INIT INFO
  13.  
  14. case "$1" in
  15.   start)
  16.     echo "Copying files to ramdisk"
  17.     rsync -av /var/www/ /memdisk/www/
  18.     rsync -av /var/lib/mysql/ /memdisk/mysql/
  19.     echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD at Start >> /var/log/memdisksync.log
  20.     ;;
  21.   sync)
  22.     echo "Synching files from ramdisk to Harddisk"
  23.     echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/memdisksync.log
  24.     rsync -av --delete --recursive --force /memdisk/www/ /var/www/
  25.     rsync -av --delete --recursive --force /memdisk/mysql/ /var/lib/mysql/
  26.     ;;
  27.   stop)
  28.     echo "Synching logfiles from ramdisk to Harddisk"
  29.     echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD on Shutdown >> /var/log/memdisksync.log
  30.     rsync -av --delete --recursive --force /memdisk/www/ /var/www/
  31.     rsync -av --delete --recursive --force /memdisk/mysql/ /var/lib/mysql/
  32.     ;;
  33.   *)
  34.     echo "Usage: /etc/init.d/ramdisk {start|stop|sync}"
  35.     exit 1
  36.     ;;
  37. esac
clone this paste RAW Paste Data