travis-backup 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -34
- data/lib/config.rb +2 -0
- data/travis-backup.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82c4a389c3ed4d73db6f9b50b4d80a17524f646b1ce4fa6737821a8e4cc7009d
|
4
|
+
data.tar.gz: 514f7b4042b0ef3297371ec5062f3d0ebcb001b1916f35b2c66e0ea6ffb4a201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3c44b552f31d73d62469cb619c516297ed7a3b02ea4694c8bc39cd2fd48cecb80a5919ec5299f0ec2ea2fc4b31c7bfcc0182cce22721d685b68f1fae921c20
|
7
|
+
data.tar.gz: 3440dff96a5940425568de23c2c714f663e2b351694d6dcd8ad70646f8627e69258386b2e415da3172cdde5ddb5b126019d555722de541d183edc187ee42289c
|
data/README.md
CHANGED
@@ -9,15 +9,30 @@ You can install the gem using
|
|
9
9
|
|
10
10
|
`gem install travis-backup`
|
11
11
|
|
12
|
-
Next you can run it
|
12
|
+
Next you can run it like:
|
13
13
|
|
14
14
|
```
|
15
|
-
|
15
|
+
travis_backup 'postgres://user:pass@localhost:5432/my_db' --threshold 6
|
16
|
+
```
|
16
17
|
|
17
|
-
|
18
|
-
backup.run
|
18
|
+
All arguments:
|
19
19
|
|
20
|
-
|
20
|
+
```
|
21
|
+
first argument, no flag # database url
|
22
|
+
-b, --backup # when not present, removes data without saving it to file
|
23
|
+
-d, --dry_run # only prints in console what data will be backuped and deleted
|
24
|
+
-l, --limit LIMIT # builds limit for one backup file
|
25
|
+
-t, --threshold MONTHS # number of months from now - data younger than this time won't be backuped
|
26
|
+
-f, --files_location PATH # path of the folder in which backup files will be placed
|
27
|
+
-u, --user_id ID # run only for given user
|
28
|
+
-o, --org_id ID # run only for given organization
|
29
|
+
-r, --repo_id ID # run only for given repository
|
30
|
+
```
|
31
|
+
|
32
|
+
Or inside your app:
|
33
|
+
|
34
|
+
```
|
35
|
+
require 'travis-backup'
|
21
36
|
|
22
37
|
backup = Backup.new(
|
23
38
|
if_backup: true,
|
@@ -32,7 +47,6 @@ backup.run
|
|
32
47
|
You can also run backup only for given user, organisation or repository:
|
33
48
|
|
34
49
|
```
|
35
|
-
backup = Backup.new
|
36
50
|
backup.run(user_id: 1)
|
37
51
|
# or
|
38
52
|
backup.run(org_id: 1)
|
@@ -42,7 +56,7 @@ backup.run(repo_id: 1)
|
|
42
56
|
|
43
57
|
### Configuration
|
44
58
|
|
45
|
-
|
59
|
+
Despite of command line arguments, one of the ways you can configure your export is a file `config/settinigs.yml` that you can place in your app's main directory. The gem expects properties in the following format:
|
46
60
|
|
47
61
|
```
|
48
62
|
backup:
|
@@ -56,7 +70,7 @@ backup:
|
|
56
70
|
repo_id # run only for given repository
|
57
71
|
```
|
58
72
|
|
59
|
-
You can also set these properties
|
73
|
+
You can also set these properties using env vars corresponding to them: `IF_BACKUP`, `BACKUP_DRY_RUN`, `BACKUP_LIMIT`, `BACKUP_THRESHOLD`, `BACKUP_FILES_LOCATION`, `USER_ID`, `ORG_ID`, `REPO_ID`.
|
60
74
|
|
61
75
|
You should also specify your database url. You can do this the standard way in `config/database.yml` file, setting the `database_url` hash argument while creating `Backup` instance or using the `DATABASE_URL` env var. Your database should be consistent with the Travis 2.2 database schema.
|
62
76
|
|
@@ -78,32 +92,6 @@ To make tests working properly you should also ensure the database connection st
|
|
78
92
|
|
79
93
|
**Warning: this database will be cleaned during tests, so ensure that it includes no important data.**
|
80
94
|
|
81
|
-
#### Using as standalone application
|
82
|
-
|
83
|
-
After cloning this repo you can also run it as a standalone app using
|
84
|
-
|
85
|
-
```
|
86
|
-
bundle exec bin/travis_backup
|
87
|
-
```
|
88
|
-
|
89
|
-
You can also pass arguments:
|
90
|
-
|
91
|
-
```
|
92
|
-
first argument, no flag # database url
|
93
|
-
-b, --backup # when not present, removes data without saving it to file
|
94
|
-
-d, --dry_run # only prints in console what data will be backuped and deleted
|
95
|
-
-l, --limit LIMIT # builds limit for one backup file
|
96
|
-
-t, --threshold MONTHS # number of months from now - data younger than this time won't be backuped
|
97
|
-
-f, --files_location PATH # path of the folder in which backup files will be placed
|
98
|
-
-u, --user_id ID # run only for given user
|
99
|
-
-o, --org_id ID # run only for given organization
|
100
|
-
-r, --repo_id ID # run only for given repository
|
101
|
-
|
102
|
-
# example:
|
103
|
-
|
104
|
-
bundle exec bin/travis_backup 'postgres://user:pass@localhost:5432/my_db' -b
|
105
|
-
```
|
106
|
-
|
107
95
|
### Ruby version
|
108
96
|
|
109
97
|
2.7.2
|
data/lib/config.rb
CHANGED
@@ -89,6 +89,8 @@ class Config
|
|
89
89
|
def abort_message(intro)
|
90
90
|
"\n#{intro} Example usage:\n"+
|
91
91
|
"\n $ bin/travis_backup 'postgres://my_database_url' --threshold 6\n" +
|
92
|
+
"\nor using in code:\n" +
|
93
|
+
"\n Backup.new(database_url: 'postgres://my_database_url', threshold: 6)\n" +
|
92
94
|
"\nYou can also set it using environment variables or config/database.yml file.\n"
|
93
95
|
end
|
94
96
|
|
data/travis-backup.gemspec
CHANGED