Posted By

brm on 06/16/15


Tagged

backup sysadmin


Versions (?)

Backup script using rsync


 / Published in: Bash
 

Simple backup script using Rsync

  1. #!/bin/sh
  2.  
  3. mtnpnt="/mnt/hd/"
  4.  
  5. src="/dir/"
  6.  
  7. disk="/dev/sd"
  8.  
  9. dest="/mnt/usb_harddrive/dest/"
  10.  
  11. if grep '/mnt/hd' /etc/mtab > /dev/null 2>&1; then
  12.  
  13. echo "already mount... - $(date)" > logfile
  14.  
  15. rsync -avm $src --exclude-from=/dir/exclude-file $dest >> logfile
  16.  
  17. df -h >> logfile
  18.  
  19. umount $disk
  20.  
  21. else
  22.  
  23. echo "not mount ... - $(date)" > logfile
  24.  
  25. mount $disk $mntpnt
  26.  
  27. if grep '/mnt/hd" /etc/mtab > /dev/null 2>&1; then
  28.  
  29. echo "mount by script... - $(date) >> filelog
  30.  
  31. rsync -avm $src --exclude-from="/dir/exclude-file $dest >> logfile
  32.  
  33. df -h >> logfile
  34.  
  35. else
  36.  
  37. echo "failed .. - $(date)" > filelog
  38.  
  39. fi
  40.  
  41. fi

Report this snippet  

You need to login to post a comment.