rtbackup 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 212b6a678d4e7dd3153fe755cf6b87a13cbe51a7
4
+ data.tar.gz: 9f6a0e378d592e3d176cbe43c3c468205c6f678d
5
+ SHA512:
6
+ metadata.gz: 37b4351eda5c87677080a75d3ad039f09143fb73e61b39ab1ba957edfc5feb45f08742436c411aa3fd9920ba04fb46353edc6faef4054856190b7e06e90dc9c3
7
+ data.tar.gz: 637e3a49d44b4a5b1485c150b119b5169c9c9abc37553687760eb7b4c34f3e84bfb0edb41b227eab21820def3daace3f562c197754856e554b50f2bf453d8159
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
13
+ .vscode/settings.json
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ # inherit_from: .rubocop_todo.yml
4
+
5
+ Layout/IndentationWidth:
6
+ Width: 4
7
+
8
+ Metrics/LineLength:
9
+ Max: 100
10
+
11
+ Metrics/MethodLength:
12
+ Max: 20
13
+
14
+ Style/Documentation:
15
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,35 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-03-30 15:34:28 +0700 using RuboCop version 0.54.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 5
10
+ # Configuration parameters: CountComments, ExcludedMethods.
11
+ Metrics/BlockLength:
12
+ Max: 69
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: CountComments.
16
+ Metrics/ClassLength:
17
+ Max: 110
18
+
19
+ # Offense count: 1
20
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
21
+ # URISchemes: http, https
22
+ Metrics/LineLength:
23
+ Max: 102
24
+
25
+ # Offense count: 1
26
+ # Configuration parameters: CountKeywordArgs.
27
+ Metrics/ParameterLists:
28
+ Max: 6
29
+
30
+ # Offense count: 1
31
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
32
+ # AllowedNames: io, id, to
33
+ Naming/UncommunicativeMethodParamName:
34
+ Exclude:
35
+ - 'bin/server_backup'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tgannon@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in server_backups.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,89 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ server_backups (0.1.21)
5
+ activesupport (~> 5.1)
6
+ aws-sdk-s3 (~> 1.8)
7
+ main (~> 6.2)
8
+ slack-notifier (~> 2.3)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (5.1.5)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (~> 0.7)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ addressable (2.5.2)
19
+ public_suffix (>= 2.0.2, < 4.0)
20
+ arrayfields (4.9.2)
21
+ aws-partitions (1.73.0)
22
+ aws-sdk-core (3.17.1)
23
+ aws-partitions (~> 1.0)
24
+ aws-sigv4 (~> 1.0)
25
+ jmespath (~> 1.0)
26
+ aws-sdk-kms (1.5.0)
27
+ aws-sdk-core (~> 3)
28
+ aws-sigv4 (~> 1.0)
29
+ aws-sdk-s3 (1.8.2)
30
+ aws-sdk-core (~> 3)
31
+ aws-sdk-kms (~> 1)
32
+ aws-sigv4 (~> 1.0)
33
+ aws-sigv4 (1.0.2)
34
+ chronic (0.10.2)
35
+ concurrent-ruby (1.0.5)
36
+ crack (0.4.3)
37
+ safe_yaml (~> 1.0.0)
38
+ diff-lcs (1.3)
39
+ fattr (2.4.0)
40
+ hashdiff (0.3.7)
41
+ i18n (0.9.5)
42
+ concurrent-ruby (~> 1.0)
43
+ jmespath (1.3.1)
44
+ main (6.2.2)
45
+ arrayfields (~> 4.7, >= 4.7.4)
46
+ chronic (~> 0.6, >= 0.6.2)
47
+ fattr (~> 2.2, >= 2.2.0)
48
+ map (~> 6.1, >= 6.1.0)
49
+ map (6.6.0)
50
+ minitest (5.11.3)
51
+ public_suffix (3.0.2)
52
+ rake (10.5.0)
53
+ rspec (3.7.0)
54
+ rspec-core (~> 3.7.0)
55
+ rspec-expectations (~> 3.7.0)
56
+ rspec-mocks (~> 3.7.0)
57
+ rspec-core (3.7.1)
58
+ rspec-support (~> 3.7.0)
59
+ rspec-expectations (3.7.0)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.7.0)
62
+ rspec-mocks (3.7.0)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.7.0)
65
+ rspec-support (3.7.1)
66
+ safe_yaml (1.0.4)
67
+ slack-notifier (2.3.2)
68
+ thread_safe (0.3.6)
69
+ tzinfo (1.2.5)
70
+ thread_safe (~> 0.1)
71
+ vcr (4.0.0)
72
+ webmock (3.3.0)
73
+ addressable (>= 2.3.6)
74
+ crack (>= 0.3.2)
75
+ hashdiff
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ bundler (~> 1.16)
82
+ rake (~> 10.5)
83
+ rspec (~> 3.0)
84
+ server_backups!
85
+ vcr (~> 4.0)
86
+ webmock (~> 3.3)
87
+
88
+ BUNDLED WITH
89
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Tyler Gannon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # Backup Website and Mysql databases to S3
2
+
3
+ Automated backup and recovery solution capable of restoring files and databases
4
+ to a given point in time.
5
+
6
+ * Incremental backups of files using [GNU Tar](https://www.gnu.org/software/tar/)
7
+ * Incremental backups of databases using binary logging
8
+ * Files are stored in a structured manner within an Amazon S3 bucket using
9
+ [AWS S3 SDK gem](https://github.com/aws/aws-sdk-ruby)
10
+
11
+ **Key assumptions made:**
12
+
13
+ * All databases except system databases will be backed up.
14
+ * Mysql database only.
15
+ * Mysql binary logging is turned on.
16
+ * The **GNU** (not BSD) version of _tar_. The GNU version includes --listed-incremental, which is needed for incremental backups.
17
+
18
+ ## Installation
19
+
20
+ Download the installation package from https://gitlab.com/zigzagau/server_backups/tags
21
+ Find the latest tag and download server_backups-0.x.x.gem from there.
22
+ Copy that file to your server.
23
+
24
+ ### Ubuntu
25
+
26
+ ```bash
27
+
28
+ sudo apt install ruby ruby-dev zlib1g-dev
29
+ sudo gem install server_backups-0.x.x.gem
30
+
31
+ ```
32
+
33
+ ### Configure Mysql Bin Logging
34
+
35
+ Add the following to your `my.cnf`, or on Ubuntu you might want to add it to `/etc/mysql/mysql.conf.d/mysqld.conf`
36
+ ```
37
+ [mysqld]
38
+ ...
39
+ server-id = 1 # Set it nicely if using replication
40
+ log_bin = /var/log/mysql/mysql-bin.log # Or your favorite location
41
+
42
+ ```
43
+
44
+ Then restart mysql:
45
+
46
+ ```
47
+ sudo service mysql restart
48
+ ```
49
+
50
+ ### Grant user read access to mysql binary logs and also to your web root
51
+
52
+ ```bash
53
+ # Make sure you know what the group ownership is, for your web root.
54
+ sudo usermod -a -G www-data ubuntu
55
+ sudo usermod -a -G mysql ubuntu
56
+ ```
57
+
58
+ ###
59
+
60
+ ## Usage
61
+
62
+ ### Set up a configuration file
63
+
64
+ Copy `backup_conf.sample.yml` to `~/.backup_conf.yml` and edit the settings.
65
+ Alternatively you can put the file anywhere, and then specify the path to the file
66
+ using the `-c` parameter, or even pipe a config file in through stdin.
67
+
68
+ The latter option is useful if you'd like to keep passwords and keys in variables,
69
+ rather than saving them to the filesystem.
70
+
71
+ ```bash
72
+ envsubst < back_conf.yml.tmpl | server_backup daily -c -
73
+ ```
74
+
75
+ ### Set up your crontab.
76
+
77
+ * Use `crontab -e` to edit cron configuration.
78
+
79
+ **Sample Crontab configuration**
80
+
81
+ ```
82
+
83
+ # Once per month:
84
+ 3 0 1 * * /usr/local/bin/server_backup monthly
85
+ # Once per week:
86
+ 5 0 * * 0 /usr/local/bin/server_backup weekly
87
+ # Once per day:
88
+ 5 0 * * 1-6 /usr/local/bin/server_backup daily
89
+ # And incremental backups once per hour
90
+ 5 1-23 * * * /usr/local/bin/server_backup incremental
91
+
92
+ ```
93
+
94
+ ### Command line parameters
95
+
96
+ #### 1) For taking backups:
97
+
98
+ some examples
99
+
100
+ ```bash
101
+ # Take a full backup and store it in the monthly backups location.
102
+ server_backup monthly
103
+
104
+ # Take a full backup as normal, but instead of backing up all databases,
105
+ # only back up `mydatabase`.
106
+ server_backup daily -d mydatabase
107
+
108
+ server_backup daily -f # only back up the files, not the database(s)
109
+ server_backup daily -b # only back up the database(s), not the files
110
+
111
+ # Take an incremental backup, but load the given configuration file.
112
+ server_backup incremental -c /etc/my_backup_configuration.cnf
113
+
114
+ ```
115
+
116
+ #### 2) List (or search) time zones for help with configuration
117
+
118
+ ```bash
119
+ server_backup zones # list all
120
+ server_backup zones america # case insensitive search for zones containing a string
121
+ ```
122
+
123
+ #### 3) Restore backups
124
+
125
+ ```bash
126
+ # Restore up to the latest backup data available on s3
127
+ server_backup restore
128
+
129
+ # Restore up to two days ago at 3pm in the configured
130
+ # time zone (see config file).
131
+ server_backup restore --up_to='two days ago at 3:00 PM'
132
+
133
+ # To make it easier to decide what time your restore point
134
+ # should be, you can write the restore point time in any time
135
+ # zone and it will be translated to the server's normal time zone.
136
+ #
137
+ # This way, if the server is in UTC and you're in Singapore, you
138
+ # don't necessarily have to do any confusing time maths in order
139
+ # to restore back to what time it was before you made a mistake
140
+ # and updated a wordpress plugin. ;)
141
+ server_backup restore --up_to='March 28 12:00 PM' --time_zone='Singapore'
142
+
143
+ ```
144
+
145
+ ```
146
+ NAME
147
+ server_backup
148
+
149
+ SYNOPSIS
150
+ server_backup (restore|zones) backup_type [options]+
151
+
152
+ PARAMETERS
153
+ backup_type (1 -> symbol(backup_type))
154
+ specifies the backup type to perform [incremental | daily | weekly |
155
+ monthly]
156
+ --config=config, -c (0 ~> config=~/.backup_conf.yml)
157
+ load configuration from YAML file
158
+ --database=database, -d (default ~> database=all)
159
+ Which database to back up, defaults to all non-system databases.
160
+ --db_only, -b (default ~> false)
161
+ If specified
162
+ --files_only=[files_only], -f (de ~> files_only)
163
+ Only work with files.
164
+ --help, -h
165
+ ```
166
+
167
+ ### Restore your application
168
+
169
+ ```bash
170
+ website_backup restore app_name
171
+ ```
172
+
173
+
174
+ * Everything in /var/www