run_database_backup 0.1.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.
@@ -0,0 +1,373 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: RunDatabaseBackup::Postgresql
8
+
9
+ &mdash; Documentation by YARD 0.9.28
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "RunDatabaseBackup::Postgresql";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (P)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../RunDatabaseBackup.html" title="RunDatabaseBackup (module)">RunDatabaseBackup</a></span></span>
41
+ &raquo;
42
+ <span class="title">Postgresql</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: RunDatabaseBackup::Postgresql
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">RunDatabaseBackup::Postgresql</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/run_database_backup/postgresql.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Class to backup PostgreSQL Description: This class is responsible for backing up PostgreSQL databases</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ <h2>
122
+ Instance Method Summary
123
+ <small><a href="#" class="summary_toggle">collapse</a></small>
124
+ </h2>
125
+
126
+ <ul class="summary">
127
+
128
+ <li class="public ">
129
+ <span class="summary_signature">
130
+
131
+ <a href="#dump-instance_method" title="#dump (instance method)">#<strong>dump</strong> &#x21d2; Object </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>Dump PostgreSQL database Description: This method is responsible for backing up PostgreSQL databases.</p>
147
+ </div></span>
148
+
149
+ </li>
150
+
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(uri:, database_name:, backup_directory:) &#x21d2; Postgresql </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+ <span class="note title constructor">constructor</span>
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>A new instance of Postgresql.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ </ul>
179
+
180
+
181
+ <div id="constructor_details" class="method_details_list">
182
+ <h2>Constructor Details</h2>
183
+
184
+ <div class="method_details first">
185
+ <h3 class="signature first" id="initialize-instance_method">
186
+
187
+ #<strong>initialize</strong>(uri:, database_name:, backup_directory:) &#x21d2; <tt><span class='object_link'><a href="" title="RunDatabaseBackup::Postgresql (class)">Postgresql</a></span></tt>
188
+
189
+
190
+
191
+
192
+
193
+ </h3><div class="docstring">
194
+ <div class="discussion">
195
+
196
+ <p>Returns a new instance of Postgresql.</p>
197
+
198
+
199
+ </div>
200
+ </div>
201
+ <div class="tags">
202
+ <p class="tag_title">Parameters:</p>
203
+ <ul class="param">
204
+
205
+ <li>
206
+
207
+ <span class='name'>uri</span>
208
+
209
+
210
+ <span class='type'>(<tt>String</tt>)</span>
211
+
212
+
213
+
214
+ &mdash;
215
+ <div class='inline'>
216
+ <p>PostgreSQL URI</p>
217
+ </div>
218
+
219
+ </li>
220
+
221
+ <li>
222
+
223
+ <span class='name'>database_name</span>
224
+
225
+
226
+ <span class='type'>(<tt>String</tt>)</span>
227
+
228
+
229
+
230
+ &mdash;
231
+ <div class='inline'>
232
+ <p>Database name</p>
233
+ </div>
234
+
235
+ </li>
236
+
237
+ <li>
238
+
239
+ <span class='name'>backup_directory</span>
240
+
241
+
242
+ <span class='type'>(<tt>String</tt>)</span>
243
+
244
+
245
+
246
+ &mdash;
247
+ <div class='inline'>
248
+ <p>Backup directory</p>
249
+ </div>
250
+
251
+ </li>
252
+
253
+ </ul>
254
+
255
+
256
+ </div><table class="source_code">
257
+ <tr>
258
+ <td>
259
+ <pre class="lines">
260
+
261
+
262
+ 13
263
+ 14
264
+ 15
265
+ 16
266
+ 17
267
+ 18</pre>
268
+ </td>
269
+ <td>
270
+ <pre class="code"><span class="info file"># File 'lib/run_database_backup/postgresql.rb', line 13</span>
271
+
272
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>uri:</span><span class='comma'>,</span> <span class='label'>database_name:</span><span class='comma'>,</span> <span class='label'>backup_directory:</span><span class='rparen'>)</span>
273
+ <span class='ivar'>@uri</span> <span class='op'>=</span> <span class='id identifier rubyid_uri'>uri</span>
274
+ <span class='ivar'>@database_name</span> <span class='op'>=</span> <span class='id identifier rubyid_database_name'>database_name</span>
275
+ <span class='ivar'>@backup_directory</span> <span class='op'>=</span> <span class='id identifier rubyid_backup_directory'>backup_directory</span>
276
+ <span class='ivar'>@file_path</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@backup_directory</span><span class='embexpr_end'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@database_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>-</span><span class='embexpr_beg'>#{</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_strftime'>strftime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y%m%d%H%M%S</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>.gz</span><span class='tstring_end'>&quot;</span></span>
277
+ <span class='kw'>end</span></pre>
278
+ </td>
279
+ </tr>
280
+ </table>
281
+ </div>
282
+
283
+ </div>
284
+
285
+
286
+ <div id="instance_method_details" class="method_details_list">
287
+ <h2>Instance Method Details</h2>
288
+
289
+
290
+ <div class="method_details first">
291
+ <h3 class="signature first" id="dump-instance_method">
292
+
293
+ #<strong>dump</strong> &#x21d2; <tt>Object</tt>
294
+
295
+
296
+
297
+
298
+
299
+ </h3><div class="docstring">
300
+ <div class="discussion">
301
+
302
+ <p>Dump PostgreSQL database Description: This method is responsible for backing up PostgreSQL databases</p>
303
+
304
+
305
+ </div>
306
+ </div>
307
+ <div class="tags">
308
+
309
+
310
+ </div><table class="source_code">
311
+ <tr>
312
+ <td>
313
+ <pre class="lines">
314
+
315
+
316
+ 22
317
+ 23
318
+ 24
319
+ 25
320
+ 26
321
+ 27
322
+ 28
323
+ 29
324
+ 30
325
+ 31
326
+ 32
327
+ 33
328
+ 34
329
+ 35
330
+ 36
331
+ 37
332
+ 38
333
+ 39</pre>
334
+ </td>
335
+ <td>
336
+ <pre class="code"><span class="info file"># File 'lib/run_database_backup/postgresql.rb', line 22</span>
337
+
338
+ <span class='kw'>def</span> <span class='id identifier rubyid_dump'>dump</span>
339
+ <span class='comment'># Check if the backup directory exists
340
+ </span> <span class='const'>FileUtils</span><span class='period'>.</span><span class='id identifier rubyid_mkdir_p'>mkdir_p</span><span class='lparen'>(</span><span class='id identifier rubyid_backup_directory'>backup_directory</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_directory?'>directory?</span><span class='lparen'>(</span><span class='id identifier rubyid_backup_directory'>backup_directory</span><span class='rparen'>)</span>
341
+
342
+ <span class='comment'># Cmd to backup PostgreSQL database
343
+ </span> <span class='id identifier rubyid_cmd'>cmd</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>pg_dumpall -a </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_uri'>uri</span><span class='embexpr_end'>}</span><span class='tstring_content'> -d </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_database_name'>database_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> | gzip &gt; </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_file_path'>file_path</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
344
+
345
+ <span class='comment'># Execute cmd
346
+ </span> <span class='id identifier rubyid_system'>system</span><span class='lparen'>(</span><span class='id identifier rubyid_cmd'>cmd</span><span class='rparen'>)</span>
347
+
348
+ <span class='comment'># Output
349
+ </span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Backup of PostgreSQL database </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_database_name'>database_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> completed</span><span class='tstring_end'>&quot;</span></span>
350
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Backup directory: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_file_path'>file_path</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
351
+ <span class='kw'>rescue</span> <span class='const'>StandardError</span>
352
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error: Backup of PostgreSQL database </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_database_name'>database_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> failed</span><span class='tstring_end'>&quot;</span></span>
353
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Verify if the PostgreSQL URI is correct and if the database name is correct</span><span class='tstring_end'>&quot;</span></span>
354
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Verify if the PostgreSQL database is running and command pg_dumpall are installed</span><span class='tstring_end'>&quot;</span></span>
355
+ <span class='kw'>end</span></pre>
356
+ </td>
357
+ </tr>
358
+ </table>
359
+ </div>
360
+
361
+ </div>
362
+
363
+ </div>
364
+
365
+ <div id="footer">
366
+ Generated on Fri Feb 24 16:24:39 2023 by
367
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
368
+ 0.9.28 (ruby-3.2.0).
369
+ </div>
370
+
371
+ </div>
372
+ </body>
373
+ </html>
@@ -0,0 +1,135 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: RunDatabaseBackup::Tasks
8
+
9
+ &mdash; Documentation by YARD 0.9.28
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "RunDatabaseBackup::Tasks";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (T)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../RunDatabaseBackup.html" title="RunDatabaseBackup (module)">RunDatabaseBackup</a></span></span>
41
+ &raquo;
42
+ <span class="title">Tasks</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: RunDatabaseBackup::Tasks
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Rails::Railtie</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Rails::Railtie</li>
78
+
79
+ <li class="next">RunDatabaseBackup::Tasks</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/run_database_backup/tasks.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>Railtie to load rake tasks Description: This class is responsible for loading rake tasks</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+ </div>
126
+
127
+ <div id="footer">
128
+ Generated on Fri Feb 24 16:24:39 2023 by
129
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
+ 0.9.28 (ruby-3.2.0).
131
+ </div>
132
+
133
+ </div>
134
+ </body>
135
+ </html>