Guest User

Untitled

a guest
Jun 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. Backpath = "/backup/apps/dljy"
  3. Now = Time.now
  4. DATE = Now.strftime("%Y-%m-%d")
  5. Dom = Now.mday # Day of month
  6. Dow = Now.wday # Day of week
  7. M = Now.month # Month of the year
  8. W = Now.strftime("%W") # Week of the year
  9. Doweekly = 6 # Saturday
  10.  
  11.  
  12. def dljybackup(bkpath)
  13. #exclude tmp&log dir and change dir to /usr/local/railsites
  14. `tar zcfP #{bkpath} --exclude "tmp" --exclude "log" -C /usr/local/railsites zcms/`
  15. end
  16.  
  17. #Create required directory
  18. #first check backup directory exist?
  19. if Dir[Backpath] == []
  20. `mkdir -p #{Backpath}`
  21. end
  22.  
  23. #check daily exist?
  24. if Dir["#{Backpath}/daily"] == []
  25. `mkdir -p '#{Backpath}/daily'`
  26. end
  27.  
  28. #check weekly exist?
  29. if Dir["#{Backpath}/weekly"] == []
  30. `mkdir -p '#{Backpath}/weekly'`
  31. end
  32.  
  33. #check monthly exist?
  34. if Dir["#{Backpath}/monthly"] == []
  35. `mkdir -p '#{Backpath}/monthly'`
  36. end
  37.  
  38. #make monthly backup
  39. if Dom=="1"
  40. bkpath=Backpath+"/monthly/dljy.tar.gz"
  41. dljybackup bkpath
  42. end
  43.  
  44. #make weekly backup
  45. if Dow==Doweekly
  46. bkpath=Backpath+"/weekly/dljy.tar.gz"
  47. dljybackup bkpath
  48. else
  49. bkpath=Backpath+"/daily/dljy.tar.gz"
  50. dljybackup bkpath
  51. end
Add Comment
Please, Sign In to add comment