Minecraft Wiki
Advertisement

I've created this backup script to aid in the administration of servers.

  • Requires Ruby (any recent one should do)
  • Can be just downloaded and run
  • Will back up the servers/ folder into timestamped backups under bak/
  • Supports multiple backups in one day
  • Requires tar and bz2

--

#!/usr/bin/ruby


# Mine_iac/Malltog's Backup Script (version 1.0)


year = `date +%Y`

date = `date +%b%0d`


year.strip!

date.strip!


Dir.mkdir('bak/' + year) unless Dir.exists?('bak/' + year)

Dir.mkdir('bak/log/' + year) unless Dir.exists?('bak/log/' + year)


if File.exists? 'bak/data'

f = File.open('bak/data', 'r')

n = f.readline.to_i

f.close

else

f = File.open('bak/data', 'w')

f.write 0.to_s

f.close

n = 0

end


lf = File.open('bak/log/' + year + '/'+ date + '-' + n.to_s + '.log', 'w')

lf.write `tar -cvjf bak/#{year}/#{date}-#{n}.tar.bz2 servers`

lf.close


f = File.open('bak/data', 'w')

f.write (n + 1).to_s

f.close


Advertisement