Created
October 23, 2013 06:54
-
-
Save lajunta/7113735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
SitesPath = "/data/sites" | |
backPath = "/backup/all" | |
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 | |
Sites=["dljy","kpy","penroll","dc","tiku"] | |
TargetDir=File.join(backPath,date) | |
`mkdir -p #{backPath}` if Dir[backPath] == [] | |
`mkdir -p #{TargetDir}` if Dir[TargetDir] == [] | |
def backup | |
#exclude tmp&log dir and change dir to /usr/local/railsites | |
Sites.each do |site| | |
thepath=File.join(TargetDir,site+".tar.gz") | |
`tar zcfP #{thepath} --exclude "tmp" --exclude "log" -C #{SitesPath} #{site}/` | |
end | |
`tar zcfP #{TargetDir+"/run.tar.gz"} -C /data run/` | |
`tar zcfP #{TargetDir+"/etc.tar.gz"} -C / etc/` | |
end | |
backup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment