rmybackup 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Readme.md +7 -0
- data/lib/rmybackup/config_file.txt +8 -1
- data/lib/rmybackup/purge_files.rb +10 -0
- data/lib/rmybackup.rb +3 -1
- metadata +3 -3
data/Readme.md
CHANGED
@@ -33,8 +33,15 @@ The default location for the configuration file is /etc/rmybackup.conf then ~/.r
|
|
33
33
|
|
34
34
|
---
|
35
35
|
backup_dir: /Users/username/mysql_backups/
|
36
|
+
|
37
|
+
#Pruning. Remove_after is evaluated first, then only_keep
|
38
|
+
|
39
|
+
#Remove after x days
|
36
40
|
remove_after: 7
|
37
41
|
|
42
|
+
#Only keep x number
|
43
|
+
only_keep: 5
|
44
|
+
|
38
45
|
#Database
|
39
46
|
username: root
|
40
47
|
password: password
|
@@ -14,4 +14,14 @@ module RMyBackup
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.purge_number(path,number=false)
|
19
|
+
return true unless number
|
20
|
+
all_files = Dir[File.join(path,"*.gz")].sort_by {|f| File.mtime(f)}.reverse
|
21
|
+
keep = all_files[0..number - 1]
|
22
|
+
remove = all_files - keep
|
23
|
+
remove.each do |f|
|
24
|
+
File.delete f
|
25
|
+
end
|
26
|
+
end
|
17
27
|
end
|
data/lib/rmybackup.rb
CHANGED
@@ -7,7 +7,7 @@ require File.expand_path('../rmybackup/purge_files',__FILE__)
|
|
7
7
|
|
8
8
|
module RMyBackup
|
9
9
|
|
10
|
-
GEM_VERSION = "0.
|
10
|
+
GEM_VERSION = "0.3.0"
|
11
11
|
|
12
12
|
class Base
|
13
13
|
def initialize(config_file)
|
@@ -44,6 +44,7 @@ module RMyBackup
|
|
44
44
|
|
45
45
|
#Purge after x days
|
46
46
|
RMyBackup.purge_days(backup_dir,@config['remove_after'])
|
47
|
+
RMyBackup.purge_number(backup_dir,@config['only_keep'])
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
@@ -73,6 +74,7 @@ module RMyBackup
|
|
73
74
|
@config['mysqldump_command'] = "/usr/bin/mysqldump" if @config['mysqldump_command'].nil?
|
74
75
|
@config['find_command'] = "/usr/bin/find" if @config['find_command'].nil?
|
75
76
|
@config['remove_after'] = @config['remove_after'] || false
|
77
|
+
@config['only_keep'] = @config['only_keep'] || false
|
76
78
|
|
77
79
|
@config['use_mycnf_credentials'] = @config['use_mycnf_credentials'] ? true : false
|
78
80
|
|