Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- Backpath = "/backup/apps/dljy"
- Now = Time.now
- DATE = Now.strftime("%Y-%m-%d")
- Dom = Now.mday # Day of month
- Dow = Now.wday # Day of week
- M = Now.month # Month of the year
- W = Now.strftime("%W") # Week of the year
- Doweekly = 6 # Saturday
- def dljybackup(bkpath)
- #exclude tmp&log dir and change dir to /usr/local/railsites
- `tar zcfP #{bkpath} --exclude "tmp" --exclude "log" -C /usr/local/railsites zcms/`
- end
- #Create required directory
- #first check backup directory exist?
- if Dir[Backpath] == []
- `mkdir -p #{Backpath}`
- end
- #check daily exist?
- if Dir["#{Backpath}/daily"] == []
- `mkdir -p '#{Backpath}/daily'`
- end
- #check weekly exist?
- if Dir["#{Backpath}/weekly"] == []
- `mkdir -p '#{Backpath}/weekly'`
- end
- #check monthly exist?
- if Dir["#{Backpath}/monthly"] == []
- `mkdir -p '#{Backpath}/monthly'`
- end
- #make monthly backup
- if Dom=="1"
- bkpath=Backpath+"/monthly/dljy.tar.gz"
- dljybackup bkpath
- end
- #make weekly backup
- if Dow==Doweekly
- bkpath=Backpath+"/weekly/dljy.tar.gz"
- dljybackup bkpath
- else
- bkpath=Backpath+"/daily/dljy.tar.gz"
- dljybackup bkpath
- end
Add Comment
Please, Sign In to add comment