Skip to content

Instantly share code, notes, and snippets.

@lajunta
Created October 23, 2013 06:54
Show Gist options
  • Save lajunta/7113735 to your computer and use it in GitHub Desktop.
Save lajunta/7113735 to your computer and use it in GitHub Desktop.
#!/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