rmybackup 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Readme.md +52 -0
  2. data/bin/rmybackup +10 -2
  3. data/lib/rmybackup.rb +7 -1
  4. metadata +3 -3
  5. data/Readme +0 -1
data/Readme.md ADDED
@@ -0,0 +1,52 @@
1
+ # RMyBackup
2
+
3
+ RMyBackup was created to solve a simple problem I had, and is hopefully useful to somebody else out there. It is a quick way to backup up specified mysql databases using mysqldump. It writes a gzipped .sql file using a date/time naming convention to a specified directory.
4
+
5
+ ### To Install
6
+ gem install rmybackup
7
+
8
+ ## Usage
9
+
10
+ The gem will install an rmybackup binary. RMyBackup will read its configuration from /etc/rmybackup.conf (a sample configuration file is shown below). RMyBackup will backup the specified databases in the databases: [] list in the configuration file.
11
+
12
+ Right now the script relies on your [mysqldump] configuration in either /etc/my.cnf or the user's ~/.my.cnf. I'm hoping to change this soon, allowing you to specify the host, user, password, and socket in the configuration file.
13
+
14
+ # example my.cnf
15
+ #
16
+ # [mysqldump]
17
+ # user = root
18
+ # password = roots_password
19
+
20
+
21
+ Once everything is set up correctly in the config file, and mysqldump is able to operate using credentials specified in the appropriate my.cnf file, you should simply be able to run the rmybackup command.
22
+
23
+ # rmybackup
24
+
25
+
26
+ ## Sample Configuration File
27
+
28
+ The default location for the configuration file is /etc/rmybackup.conf, formatted in YAML. You can specify a different config file on the command line using the --config_file (-f) switch.
29
+
30
+ #Configuration File in YAML format
31
+
32
+ #Backup Directory
33
+ backup_dir: /Users/bshelton/mysql_tmp
34
+
35
+ database_connection:
36
+ host: localhost
37
+ user: root
38
+ password: batman
39
+
40
+ #Databases to back up
41
+ databases: [
42
+ bercilak,
43
+ etrack,
44
+ bbpress
45
+ ]
46
+
47
+ #Command Locations
48
+ mysqldump_command: /usr/local/mysql/bin/mysqldump
49
+ gzip_command: /usr/bin/gzip
50
+ find_command: /usr/bin/find
51
+
52
+ If mysqldump_command, gzip_command, or find_command are left out, they will default to finding the applications in /usr/bin
data/bin/rmybackup CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- #Load the libraries, see if we're local or not for testing
3
+ #Load our libraries, if we can't load them from the gem, assume we're running from source
4
4
  begin
5
5
  require 'rubygems'
6
6
  require 'rmybackup'
@@ -10,14 +10,22 @@ end
10
10
 
11
11
  require 'optparse'
12
12
 
13
+ #Set some globals
13
14
  OPTIONS = { :config_file => "/etc/rmybackup.conf" }
14
- GEM_VERSION = "0.0.1"
15
+ GEM_VERSION = "0.0.3"
15
16
 
17
+ #Process the command line arguments
16
18
  ARGV.options do |opts|
17
19
  opts.on("-f /etc/rmybackup.conf","--config_file /etc/rmybackup.conf","Set Config File",String) { |OPTIONS[:config_file]| }
18
20
  opts.on("-v","--version","Outputs version") { puts "Version - #{GEM_VERSION}"; exit }
19
21
  opts.parse!
20
22
  end
21
23
 
24
+ #If the config file doesn't exist, warn and exit
25
+ if not File.exists? OPTIONS[:config_file]
26
+ puts "Unable to read the configuration file - #{OPTIONS[:config_file]}"
27
+ exit
28
+ end
29
+
22
30
  #Run
23
31
  RMyBackup.new(OPTIONS[:config_file])
data/lib/rmybackup.rb CHANGED
@@ -40,7 +40,13 @@ class RMyBackup
40
40
  @config['backup_dir'] += "/" unless @config['backup_dir'][-1,1] == "/"
41
41
 
42
42
  #Run Some checks
43
- @error << "No Such Backup Directory #{@config['backup_dir']}" unless File.directory? @config['backup_dir']
43
+ if not File.directory? @config['backup_dir']
44
+ @error << "No Such Backup Directory #{@config['backup_dir']}"
45
+ else
46
+ if not File.writable? @config['backup_dir']
47
+ @error << "Can't write to the backup directory - #{@config['backup_dir']}"
48
+ end
49
+ end
44
50
 
45
51
  #Check Commands
46
52
  @error << "Can't locate find command: #{@config['find_command']}" unless File.exists? @config['find_command']
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bryan Shelton
@@ -28,7 +28,7 @@ extra_rdoc_files: []
28
28
 
29
29
  files:
30
30
  - lib/rmybackup.rb
31
- - Readme
31
+ - Readme.md
32
32
  has_rdoc: true
33
33
  homepage: http://github.com/bshelton229/rmybackup/
34
34
  licenses: []
data/Readme DELETED
@@ -1 +0,0 @@
1
- #RMyBackup runs mysql dumps from an /etc/rmybackup.conf file