Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 37 lines (23 sloc) 0.782 kb
e61f8c50 »
2009-05-26 initial import
1 #!/usr/bin/ruby
2 require 'backup_config.rb'
3 puts 'Backing up all sql dbs'
4
5 NOW = Time.now.strftime("%m_%d_%Y")
6 NOW_WITH_TIME = Time.now.strftime("%m_%d_%Y_%H_%M_%S")
7
8 #Make the foldername
9 FOLDERNAME = "backup_#{NOW}"
10
11 #Make the filename
12 FILENAME = "sqldump-#{NOW_WITH_TIME}.sql"
13
14
15 #DUMP IT !
16 command = "mysqldump -u #{USERNAME} --password=#{PASSWORD} --all-databases >> #{FILENAME}"
17 FILE_LOCATION = "#{BACKUP_LOCATION}/#{FOLDERNAME}"
18 move_command = "mv #{FILENAME} #{FILE_LOCATION}/"
19
20 #run it
21 system(command)
22 puts 'All dbs were backed up correctly'
23 puts 'Moving file...'
24
25 unless File.directory? FILE_LOCATION
26 puts 'The directory does not exist...creating'
27 system("mkdir #{FILE_LOCATION}")
28 end
29
30 system(move_command)
31 puts "The file was stored at #{FILE_LOCATION}/#{FILENAME}"
32
33
34
35
36
Something went wrong with that request. Please try again.