Opened 18 years ago
Closed 18 years ago
#119 closed defect (fixed)
Backup script of the track wikis
| Reported by: | leo | Owned by: | leo |
|---|---|---|---|
| Priority: | critical | Milestone: | UTGB Core 1.0 |
| Component: | Documentation | Version: | |
| Keywords: | Cc: |
Description
cron script
Change History (2)
comment:1 Changed 18 years ago by
comment:2 Changed 18 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note: See
TracTickets for help on using
tickets.

done.
require "stringio" require "fileutils" require "pathname" $dryrun = ARGV.include?("--dryrun") puts "running in dry run mode" if $dryrun sshGatewayIndex = ARGV.index("-g") sshCommand = sshGatewayIndex ? "ssh #{ARGV[sshGatewayIndex+1]} ssh" : "ssh" def eval(command) result = StringIO.new("", "w") IO.popen(command) do |p| p.each_line { |l| result.puts(l) } end return result.string end def run(command) puts command if !$dryrun IO.popen(command) do |p| p.each_line { |l| puts(l) } end end end def createDir(dir) puts "create a directory: #{dir}" if !(File.directory?(dir)) if !$dryrun FileUtils.mkdir_p(dir) end end date=eval("date '+%Y-%m-%d'") puts date backup_dir = "backup" # trac #run("rsync -e ssh -av sprite:/home/web/svn/trac #{backup_dir}/trac/sprite") #run("rsync -e ssh -av moonlight:/home/web/svn/trac #{backup_dir}/trac/moonlight") # backup folders servername => [folder_list] backup_list = { "moonlight.xerial.org" => ["/home/web/moonlight.xerial.org", "/home/web/svn.utgenome.org", "/home/web/trac", "/home/web/trac.utgenome.org", "/home/web/utgenome.org", "/home/web/svn/private" ], "sprite.xerial.org" => [ "/home/web/cron", "/home/web/xerial.org", "/home/web/trac", "/home/web/rails", "/home/web/svn/private" ], "dps.cb.k.u-tokyo.ac.jp" => [], "dev.utgenome.org" => [], "leaf.gi.k.u-tokyo.ac.jp" => ["/var/www/htdocs"] } # /etc/httpd/{conf,conf.d} conf_dir=["/etc/httpd/conf", "/etc/httpd/conf.d", "/etc/init.d/"] backup_list.each_key do |server| backup_dirs = conf_dir + backup_list[server] backup_dirs.each do |target_dir| target_dir = "/" + target_dir if !(target_dir.match(/^\//)) save_dir = "#{backup_dir}/server/#{server}#{target_dir}" createDir(save_dir); run("rsync -e \"#{sshCommand}\" -av #{server}:#{target_dir}/ #{save_dir}") end end