stellar-core-backup 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6155ceecee6b25c41b2489c31f68781f194eb610
4
+ data.tar.gz: b3a29645d58230e00a817c3a80152d193e597295
5
+ SHA512:
6
+ metadata.gz: 86ea0707f78f3e6002d93cfecf50781c6cd8688861b14fbddff685d531c28f14a46e81b6164468f3cdc1f551c5962f5c28e03f872b603b743fe1fe49807edcef
7
+ data.tar.gz: 0070acbe82d29852503aad3d990e58572d6cdab4368da34a6f7585188d47d2ab4117ac8ffc6f4d450148174fa3ed79c913c9988bace047a2d873e48057a195b2
@@ -0,0 +1,18 @@
1
+ stellar-core-backup-*.gem
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ out.sql
17
+ .DS_Store
18
+ *.swp
@@ -0,0 +1,58 @@
1
+ # How to contribute
2
+
3
+ Your contributions to the Stellar network will help improve the world’s financial
4
+ infrastructure, faster.
5
+
6
+ We want to make it as easy as possible to contribute changes that
7
+ help the Stellar network grow and thrive. There are a few guidelines that we
8
+ ask contributors to follow so that we can merge your changes quickly.
9
+
10
+ ## Getting Started
11
+
12
+ * Create a GitHub issue for your contribution, assuming one does not already exist.
13
+ * Clearly describe the issue including steps to reproduce if it is a bug.
14
+ * Fork the repository on GitHub
15
+
16
+ ## Making Changes
17
+
18
+ * Create a topic branch from where you want to base your work.
19
+ * This is usually the master branch.
20
+ * Please avoid working directly on the `master` branch.
21
+ * Make sure you have added the necessary tests for your changes, and make sure all tests pass.
22
+
23
+ ## Submitting Changes
24
+
25
+ * <a href="https://docs.google.com/forms/d/1g7EF6PERciwn7zfmfke5Sir2n10yddGGSXyZsq98tVY/viewform?usp=send_form">Sign the Contributor License Agreement</a>.
26
+ * All content, comments, and pull requests must follow the [Stellar Community Guidelines](https://www.stellar.org/community-guidelines/).
27
+ * Push your changes to a topic branch in your fork of the repository.
28
+ * Submit a pull request to the [stellar-core-backup repository](https://github.com/stellar/stellar-core-backup) in the Stellar organization.
29
+ * Include a descriptive [commit message](https://github.com/erlang/otp/wiki/Writing-good-commit-messages).
30
+ * Changes contributed via pull request should focus on a single issue at a time.
31
+ * Rebase your local changes against the master branch. Resolve any conflicts that arise.
32
+
33
+ At this point you're waiting on us. We like to at least comment on pull requests within three
34
+ business days (and, typically, one business day). We may suggest some changes or improvements or alternatives.
35
+
36
+ ## Making Trivial Changes
37
+
38
+ ### Documentation
39
+ For changes of a trivial nature to comments and documentation, it is not
40
+ always necessary to create a new GitHub issue. In this case, it is
41
+ appropriate to start the first line of a commit with 'doc' instead of
42
+ an issue number.
43
+
44
+ # Additional Resources
45
+
46
+ * [Bug tracker (Github)](https://github.com/stellar/stellar-core-backup/issues)
47
+ * <a href="https://docs.google.com/forms/d/1g7EF6PERciwn7zfmfke5Sir2n10yddGGSXyZsq98tVY/viewform?usp=send_form">Contributor License Agreement</a>
48
+ * [Readme for stellar-core-backup](https://github.com/stellar/stellar-core-backup/blob/master/README.md)
49
+ * #dev channel on [Slack](http://slack.stellar.org)
50
+
51
+
52
+ This document is inspired by:
53
+
54
+ https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md
55
+
56
+ https://github.com/thoughtbot/factory_girl_rails/blob/master/CONTRIBUTING.md
57
+
58
+ https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [2015] [Stellar Development Foundation]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,92 @@
1
+ # StellarCoreBackup
2
+
3
+ This application is a simple backup/restore library which creates offline/cold backups and pushes them to S3. Backups can be restored automatically but the bucket data directory needs to be emptied first as stellar-core-backup doesn't overwrite existing data. This clean out can be done manually or by using the `--clean` option with `--restore`.
4
+
5
+ All options are configurable in a config file passed in with the `--config` argument.
6
+
7
+ ## Assumptions about environment
8
+
9
+ At present `stellar-core-backup` makes a few assumptions about the environment and it expects stellar-core to be installed using the official Debian binary packages available at [https://github.com/stellar/packages](). In the event that your own environment differs from this, `stellar-core-backup` will likely break.
10
+
11
+ AWS credentials can be exported as environment variables or permissions can be granted by an IAM instance role.
12
+
13
+ ## GPG Backup Signing and Verification
14
+
15
+ To ensure archive consistency and integrity `stellar-core-backup` can use GPG signing and verification. This is enabled by default but can be disabled using the `--no-verify` argument.
16
+
17
+ The GPG key needs to be installed first which can be done using the `--getkey` command.
18
+
19
+ We are using SKS Keyservers for public key distribution available at hkp://pool.sks-keyservers.net.
20
+
21
+ ## Configuration
22
+
23
+ | config param | description |
24
+ |--------------|-------------|
25
+ |working_dir| Path to working directory which will hold temporary files, needs sufficient space to store and untar 1 backup|
26
+ |core_config| Path to stellar-core configuration file of the node we are backing up, retrieves database credentials, etc.|
27
+ |backup_dir| Path to directory which will hold the final backup|
28
+ |s3_region| S3 region|
29
+ |s3_bucket| S3 bucket to store/retrieve buckets to/from|
30
+ |s3_path| S3 Path prefix, can be used for backing up multiple core nodes to the same bucket|
31
+ |gpg_key| GPG key ID used for signing and verification of the stellar-core backups. The provided ID is the Stellar public key|
32
+
33
+ ## Usage As Command Line Tool
34
+
35
+ ##### install public GPG key
36
+
37
+ ```
38
+ stellar-core-backup --config /etc/stellar/stellar-core-backup.conf --getkey
39
+ ```
40
+
41
+ ##### backup data, create SHA256SUMS file, GPG sign it and push to S3
42
+
43
+ ```
44
+ stellar-core-backup --config /etc/stellar/stellar-core-backup.conf --backup
45
+ ```
46
+
47
+ ##### restore latest backup from S3 with auto-clean
48
+
49
+ ```
50
+ stellar-core-backup --config /etc/stellar/stellar-core-backup.conf --restore --clean
51
+ ```
52
+
53
+ ##### list arbitrary number of backups in S3 bucket
54
+
55
+ ```
56
+ stellar-core-backup --config /etc/stellar/stellar-core-backup.conf --list [num]
57
+ ```
58
+
59
+ ##### restore from selected backup file with auto-clean
60
+
61
+ ```
62
+ stellar-core-backup --config /etc/stellar/stellar-core-backup.conf --restore --clean --select [bucket-prefix/core-backup-name]
63
+ ```
64
+
65
+ ## Usage as a Library
66
+
67
+ ```ruby
68
+ require 'stellar-core-backup'
69
+
70
+ if options[:backup] then
71
+ scb = StellarCoreBackup::Job.new(
72
+ :config => '/etc/stellar/stellar-core-backup.conf',
73
+ :type => 'backup'
74
+ )
75
+ scb.run()
76
+ elsif options[:restore]
77
+ scb = StellarCoreBackup::Job.new(
78
+ :config => '/etc/stellar/stellar-core-backup.conf',
79
+ :type => 'restore'
80
+ )
81
+ scb.run()
82
+ end
83
+ ```
84
+
85
+ ## Contributing
86
+
87
+ 1. Fork it ( https://github.com/[my-github-username]/stellar-core-backup/fork )
88
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
89
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
90
+ 4. Push to the branch (`git push origin my-new-feature`)
91
+ 5. Create a new Pull Request
92
+
@@ -0,0 +1,9 @@
1
+ task :build do
2
+ system "gem build stellar-core-backup.gemspec"
3
+ end
4
+
5
+ task :install => :build do
6
+ system "gem install --local --user-install stellar-core-backup"
7
+ system "sudo gem install --local stellar-core-backup"
8
+ end
9
+
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+ # requires IAM role/Environment variables for aws auth
3
+ require 'stellar-core-backup'
4
+ require 'optparse'
5
+
6
+
7
+ options = { listlen: 1, verify: true}
8
+
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: #{$0} [options]"
11
+ opts.on("-b", "--backup", "cold backup stellar-core") do |backup|
12
+ options[:type] = 'backup'
13
+ end
14
+ opts.on("-c CONFIG", "--config", "configuration file to use") do |config|
15
+ options[:config] = config
16
+ end
17
+ opts.on("-C", "--clean", "auto-clean buckets directory") do |clean|
18
+ options[:clean] = 'clean'
19
+ end
20
+ opts.on("-g", "--getkey", "load or update the configured public GPG key") do |getkey|
21
+ options[:type] = 'getkey'
22
+ end
23
+ opts.on("-l", "--list [NUM]", Numeric, "list latest backup or display NUM backups") do |list|
24
+ options[:type] = 'list'
25
+ options[:listlen] = list if list
26
+ end
27
+ opts.on("-r", "--restore", "offline restore, uses latest backup") do |restore|
28
+ options[:type] = 'restore'
29
+ end
30
+ opts.on("-s", "--select backup_file", "select archive for point in time restore") do |select|
31
+ options[:select] = select
32
+ end
33
+ opts.on("--no-verify", "don't PGP sign backed up shasum file or verify restore files integrity (default on)") do |notverify|
34
+ options.delete(:verify)
35
+ end
36
+ end.parse!
37
+
38
+ if ! options[:type] then
39
+ puts "error: no operation specified; exiting\n"
40
+ else
41
+ scb = StellarCoreBackup::Job.new(options)
42
+ scb.run()
43
+ end
44
+
45
+ exit
46
+
@@ -0,0 +1,7 @@
1
+ working_dir: /mnt/xvdf
2
+ core_config: /etc/stellar/stellar-core.cfg
3
+ backup_dir: /var/lib/stellar/backups
4
+ s3_region: us-east-1
5
+ s3_bucket: stellar002-core-backups
6
+ s3_path: testnet
7
+ gpg_key: 'D99E1D15ACC358AB'