Skip to content

Commit e7ee500

Browse files
authored
Cleaned up backup and restore procedure in Administration Guide (#3756)
* Cleaned up backup and restore procedure in Administration Guide #3749 * admin user does not exist in container #3751
1 parent 30a2d24 commit e7ee500

File tree

2 files changed

+61
-24
lines changed

2 files changed

+61
-24
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Cleaned up backup and restore procedure in Administration Guide
12
- Removed misleading admonition at the beginning of the Replace
23
Certificates section in the Administration Guide
34
- Added note about cache_dir size in Installation and Upgrade

modules/administration/pages/backup-restore.adoc

+60-24
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,8 @@ To access a shell inside the Server container, run [literal]``mgrctl term`` on t
117117
From there, one can run the CLI tools as usual.
118118
====
119119

120-
[IMPORTANT]
121-
====
122-
The [command]``smdba`` tool requires [command]``sudo`` access, to execute system changes.
123-
Ensure you have enabled [command]``sudo`` access for the [username]``admin`` user before you begin, by checking the [path]``/etc/sudoers`` file for this line:
124-
125-
----
126-
admin ALL=(postgres) /usr/bin/smdba
127-
----
128-
129-
====
130120

131-
Check the runtime status of your database with:
121+
Check the runtime status of the database with:
132122

133123
----
134124
smdba db-status
@@ -197,43 +187,54 @@ Regular database backups do not require any downtime.
197187
This becomes a permanent target for your backup, so ensure it remains accessible by your server at all times.
198188
This directory is on persistent storage, and for more information, see xref:installation-and-upgrade:container-management/persistent-container-volumes.adoc[].
199189
. At the command prompt of the {productname} container host, as root, enter the server container:
190+
200191
+
201192

193+
[source,shell]
202194
----
203195
mgrctl term
204196
----
205197

206198
. Inside the container, execute the following steps:
199+
207200
+
208201

209202
--
210203
.. In your backup location, create a directory for the backup:
204+
211205
+
206+
212207
As root:
208+
213209
+
210+
211+
[source,shell]
214212
----
215213
install -d -o postgres -g postgres -m 700 /var/spacewalk/db-backup
216214
----
217-
.. Ensure you have the correct permissions set on the backup location:
218-
+
219-
----
220-
chown postgres:postgres /var/spacewalk/db-backup
221-
----
222-
+
215+
223216
.. To create a backup for the first time, run the [command]``smdba backup-hot`` command with the [option]``enable`` option set.
224217
This creates the backup in the specified directory, and, if necessary, restart the database:
218+
225219
+
220+
221+
[source,shell]
226222
----
227223
smdba backup-hot --enable=on --backup-dir=/var/spacewalk/db-backup
228224
----
225+
229226
+
227+
230228
This command produces debug messages and finishes sucessfully with the output:
229+
231230
+
231+
232232
----
233233
INFO: Finished
234234
----
235-
+
235+
236236
.. Check that the backup files exist in the [path]``/var/spacewalk/db-backup`` directory, to ensure that your backup has been successful.
237+
237238
--
238239

239240

@@ -250,6 +251,7 @@ We recommend you schedule regular database backups for a low-traffic period, to
250251
Ensure you have at least three times the current database size of space available for backups.
251252
You can check your current database size by running on the container host:
252253
254+
[source,shell]
253255
----
254256
mgrctl exec "df -h /var/lib/pgsql"
255257
----
@@ -259,61 +261,77 @@ mgrctl exec "df -h /var/lib/pgsql"
259261
.Procedure: Creating a directory for the backup (do it only once)
260262

261263
. At the command prompt of the {productname} container host, as root, enter the server container:
264+
262265
+
263266

267+
[source,shell]
264268
----
265269
mgrctl term
266270
----
267271

268272
. Inside the container, execute the following steps:
273+
269274
+
270275

271276
--
272277
.. In your backup location, create a directory for the backup.
273278
As root, enter:
279+
274280
+
281+
282+
[source,shell]
275283
----
276284
install -d -o postgres -g postgres -m 700 /var/spacewalk/db-backup
277285
----
278-
.. Ensure you have the correct permissions set on the backup location:
279-
+
280-
----
281-
chown postgres:postgres /var/spacewalk/db-backup
282-
----
286+
283287
--
284288

285289

286290
.Procedure: Scheduling Automatic Backups
287291
. On the container host, as root, create a system unit file at [path]``/etc/systemd/system/server-db-backup.service`` with the content:
292+
288293
+
294+
289295
----
290296
[Unit]
291297
Description="Server backup service"
292298
293299
[Service]
294300
ExecStart=mgrctl exec "smdba backup-hot --enable=on --backup-dir=/var/spacewalk/db-backup"
295301
----
302+
296303
. Create a systemd timer file at [path]``/etc/systemd/system/server-db-backup.timer`` with the content:
304+
297305
+
306+
298307
----
299308
[Unit]
300309
Description="Run server database backup relative to activation time"
301310
302311
[Timer]
303-
OnCalendar=Mo..Sun *-*-* 2:00:00
312+
OnCalendar=Mon..Sun *-*-* 2:00:00
304313
Unit=server-db-backup.service
305314
306315
[Install]
307316
WantedBy=multi-user.target
308317
----
318+
309319
+
320+
310321
. Check that all configuration are correct:
322+
311323
+
324+
325+
[source,shell]
312326
----
313327
systemd-analyze verify /etc/systemd/system/server-db-backup.*
314328
----
329+
315330
. Enable the timer:
331+
316332
+
333+
334+
[source,shell]
317335
----
318336
systemctl enable --now server-db-backup.timer
319337
----
@@ -329,33 +347,51 @@ The [command]``smdba`` tool can be used to restore from backup in the case of fa
329347

330348
.Procedure: Restoring from Backup
331349
. At the command prompt of the {productname} container host, as root, enter the server container:
350+
332351
+
333352

353+
[source,shell]
334354
----
335355
mgrctl term
336356
----
337357

338358
. Inside the container, execute the following steps:
359+
339360
+
340361

341362
--
342363
.. Shut down the database:
364+
343365
+
366+
367+
[source,shell]
344368
----
345369
smdba db-stop
346370
----
371+
347372
.. Start the restore process and wait for it to complete:
373+
348374
+
375+
376+
[source,shell]
349377
----
350378
smdba backup-restore start
351379
----
380+
352381
.. Restart the database:
382+
353383
+
384+
385+
[source,shell]
354386
----
355387
smdba db-start
356388
----
389+
357390
.. Check if there are differences between the RPMs and the database.
391+
358392
+
393+
394+
[source,shell]
359395
----
360396
spacewalk-data-fsck
361397
----

0 commit comments

Comments
 (0)