palisade 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a162b4ca0bdff784635203afb9a5b7a1ce81e0ef
4
- data.tar.gz: f7c796718c580058c54ecd8e24f17848f5bd7052
3
+ metadata.gz: 6be72549c6a94a8a615a45b64ff95cd7903f8ed9
4
+ data.tar.gz: a82ad1ca51611fdf1dabe77394ac4dd3757f0fed
5
5
  SHA512:
6
- metadata.gz: 190ee698ade4b69cd481f041892e649441bbab8d19e84c3fdc63cf899de22223fcccab401b2d8d5ccde64eb0c1c6459bb1dcc7f2e448515a268d8b81afd805d8
7
- data.tar.gz: 07e662bb8dd030665dd3e830b5e64fb0d2a4af4987cd84682d81151d7fe01687c75af524a7b227a1d7fb23cbd6cca514a629a3352736f6a534e464d97e2a3fb5
6
+ metadata.gz: 9355ba9498ccc78f80a3ee28cd409b75a2c2ccf226eeb6d1d389561e73290177384a18000a6bf0fa9068280e115e5ca12d0ed8e45e6ae097ad75933383e8e6ae
7
+ data.tar.gz: 90d516bffa251b4aa31909f27cba7ba48644bdf9f449db717c49c0637a297d51e2456cea2d0b6c25863eaba9663025c0adfa6ef142796cc560e4b37dc7b744f9
data/.gitignore CHANGED
@@ -12,3 +12,6 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+
16
+ # Test backups
17
+ test/backups/
data/bin/palisade ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'palisade/install'
4
+ require 'palisade/backup'
5
+
6
+ action = ARGV[0]
7
+
8
+ case action
9
+ when 'install'
10
+ Palisade::Install.add_config
11
+ when 'backup'
12
+ Palisade::Backup.backup
13
+ else
14
+ puts "Usage: palisade [ACTION]"
15
+ end
@@ -0,0 +1,10 @@
1
+
2
+ ------------------------------
3
+
4
+ Palisade added a config file here:
5
+
6
+ #{@vars[:config_file]}
7
+
8
+ Edit this file and then start building your wall!
9
+
10
+ ------------------------------
@@ -0,0 +1,110 @@
1
+ require 'yaml'
2
+ require 'fileutils'
3
+
4
+ module Palisade
5
+ class Backup
6
+
7
+ def initialize
8
+ end
9
+
10
+ def self.backup
11
+ Palisade::Backup.new.backup
12
+ end
13
+
14
+ def backup
15
+ do_the_backup
16
+ end
17
+
18
+ private
19
+
20
+ def do_the_backup
21
+ projects.each do |name, config|
22
+ verify_project_dir(name)
23
+ if config['db']
24
+ verify_db_dir(name)
25
+ rsync(config['db'], db_dir(name))
26
+ end
27
+ if config['assets']
28
+ method = config['assets']['method']
29
+ method = 'rsync' if method.nil? || method == ''
30
+ case method
31
+ when 'rsync'
32
+ config['assets'].each do |asset_name, url|
33
+ unless asset_name == 'method'
34
+ # verify_asset_dir(name, asset_name)
35
+ rsync(url, project_dir(name))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def rsync(src, dest)
44
+ system("rsync #{rsync_options} #{src} #{dest}")
45
+ end
46
+
47
+ # ------------------------------------------ Directory Management
48
+
49
+ def project_dir(name)
50
+ "#{dest_root}/#{name}"
51
+ end
52
+
53
+ def db_dir(name)
54
+ "#{project_dir(name)}/db"
55
+ end
56
+
57
+ # def asset_dir(project_name, asset_name)
58
+ # "#{project_dir(project_name)}/#{asset_name}"
59
+ # end
60
+
61
+ def verify_project_dir(name)
62
+ unless Dir.exists?(project_dir(name))
63
+ FileUtils.mkdir_p(project_dir(name))
64
+ end
65
+ end
66
+
67
+ def verify_db_dir(name)
68
+ unless Dir.exists?(db_dir(name))
69
+ FileUtils.mkdir_p(db_dir(name))
70
+ end
71
+ end
72
+
73
+ # def verify_asset_dir(project_name, asset_name)
74
+ # unless Dir.exists?(asset_dir(project_name, asset_name))
75
+ # FileUtils.mkdir_p(asset_dir(project_name, asset_name))
76
+ # end
77
+ # end
78
+
79
+ # ------------------------------------------ Configuration / Options
80
+
81
+ def config_file
82
+ @config_file ||= "#{`echo $HOME`.strip}/.palisade/config.yml"
83
+ end
84
+
85
+ def load_config
86
+ @load_config ||= YAML.load_file(config_file)
87
+ end
88
+
89
+ def config
90
+ @config ||= load_config['config']
91
+ end
92
+
93
+ def projects
94
+ @projects ||= load_config['projects']
95
+ end
96
+
97
+ def dest_root
98
+ @dest_root ||= config['root']
99
+ end
100
+
101
+ def rsync_options
102
+ @rsync_options ||= '-chavz --stats'
103
+ end
104
+
105
+ def daystamp
106
+ @daystamp ||= Time.now.strftime('%d')
107
+ end
108
+
109
+ end
110
+ end
@@ -0,0 +1,60 @@
1
+ require 'fileutils'
2
+ require 'palisade/message'
3
+
4
+ module Palisade
5
+ class Install
6
+
7
+ def initialize
8
+ end
9
+
10
+ def self.add_config
11
+ Palisade::Install.new.add_config
12
+ end
13
+
14
+ def add_config
15
+ mk_config_dir
16
+ copy_config_file
17
+ print_install_message
18
+ end
19
+
20
+ private
21
+
22
+ def home_dir
23
+ `echo $HOME`.strip
24
+ end
25
+
26
+ def config_dir
27
+ "#{home_dir}/.palisade"
28
+ end
29
+
30
+ def config_file
31
+ "#{config_dir}/config.yml"
32
+ end
33
+
34
+ def config_template
35
+ File.expand_path('../../templates/config.yml', __FILE__)
36
+ end
37
+
38
+ def mk_config_dir
39
+ unless Dir.exists?(config_dir)
40
+ FileUtils.mkdir(config_dir)
41
+ end
42
+ end
43
+
44
+ def copy_config_file
45
+ unless File.exists?(config_file)
46
+ system("cp #{config_template} #{config_file}")
47
+ end
48
+ end
49
+
50
+ def print_install_message
51
+ Palisade::Message.print(
52
+ :install,
53
+ {
54
+ :config_file => config_file
55
+ }
56
+ )
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,28 @@
1
+ module Palisade
2
+ class Message
3
+
4
+ def initialize(name, vars = {})
5
+ @name = name
6
+ @vars = vars
7
+ end
8
+
9
+ def self.print(name, vars = {})
10
+ Palisade::Message.new(name.to_s, vars).print
11
+ end
12
+
13
+ def print
14
+ puts template_contents
15
+ end
16
+
17
+ private
18
+
19
+ def template_file
20
+ File.expand_path("../../messages/#{@name}.txt", __FILE__)
21
+ end
22
+
23
+ def template_contents
24
+ eval('"' + File.read(template_file) + '"')
25
+ end
26
+
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Palisade
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/palisade.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "palisade/version"
2
2
 
3
3
  module Palisade
4
- # Your code goes here...
5
4
  end
@@ -0,0 +1,54 @@
1
+ # -------------------
2
+ # This is your main configuration file for Palisade. It
3
+ # drives the backups run by Palisade. Edit this to your
4
+ # liking and then start backing up!
5
+ # -------------------
6
+ config:
7
+ # -------------------
8
+ # This is the root path to where your backups should be
9
+ # stored.
10
+ #
11
+ # This path should be accessible whenever the computer is
12
+ # on. So, if it's an external drive, you'll need to make
13
+ # sure it's always connected.
14
+ # -------------------
15
+ root: /path/to/my/backups
16
+ # -------------------
17
+ # This is where you store your backup settings. Each backup
18
+ # is broken down as a project, which can have assets (files)
19
+ # and a database. See the example below.
20
+ # -------------------
21
+ projects:
22
+ # -------------------
23
+ # The key should be a unique identifier for the project.
24
+ # -------------------
25
+ my_first_project:
26
+ # -------------------
27
+ # `db` is the path to the database. If it is remote, use
28
+ # a full ssh url. You can use ssh config shorthand
29
+ # methods.
30
+ #
31
+ # Note: You'll need a nightly dump of this database for
32
+ # this to work.
33
+ # -------------------
34
+ db: myserver.com:~/backups/my_app_production.sql
35
+ # -------------------
36
+ # `assets` should stay as it is and have NO VALUE
37
+ # -------------------
38
+ assets:
39
+ # -------------------
40
+ # `method` is the method by which we're going to back
41
+ # up the assets.
42
+ #
43
+ # Options: rsync, s3cmd
44
+ #
45
+ # You should make sure the method you're using is
46
+ # installed on your machine.
47
+ # -------------------
48
+ method: rsync
49
+ # -------------------
50
+ # From here, you can add as many keys as you want, and
51
+ # each can have their own remote ssh url.
52
+ # -------------------
53
+ files: deploy@192.168.1.1:~/apps/my_app/shared/files
54
+ uploads: deploy@192.168.1.1:~/apps/my_app/shared/files
data/palisade.gemspec CHANGED
@@ -18,6 +18,21 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.post_install_message = "
22
+ ------------------------------
23
+
24
+ Thanks for installing Palisade!
25
+
26
+ Before you start building your wall, you need to install a
27
+ config file. Don't forget to run this command:
28
+
29
+ palisade install
30
+
31
+ And then edit the config file!
32
+
33
+ ------------------------------
34
+ "
35
+
21
36
  spec.add_development_dependency "bundler", "~> 1.7"
22
37
  spec.add_development_dependency "rake", "~> 10.0"
23
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: palisade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean C Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-22 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -41,7 +41,8 @@ dependencies:
41
41
  description: Automate regular backups of remote data.
42
42
  email:
43
43
  - scdavis41@gmail.com
44
- executables: []
44
+ executables:
45
+ - palisade
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
@@ -50,14 +51,23 @@ files:
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile
54
+ - bin/palisade
55
+ - lib/messages/install.txt
53
56
  - lib/palisade.rb
57
+ - lib/palisade/backup.rb
58
+ - lib/palisade/install.rb
59
+ - lib/palisade/message.rb
54
60
  - lib/palisade/version.rb
61
+ - lib/templates/config.yml
55
62
  - palisade.gemspec
56
63
  homepage: ''
57
64
  licenses:
58
65
  - MIT
59
66
  metadata: {}
60
- post_install_message:
67
+ post_install_message: "\n ------------------------------\n\n Thanks for installing
68
+ Palisade! \n\n Before you start building your wall, you need to install a\n config
69
+ file. Don't forget to run this command:\n\n palisade install\n\n And then
70
+ edit the config file!\n\n ------------------------------\n "
61
71
  rdoc_options: []
62
72
  require_paths:
63
73
  - lib