Implementar un sistema de copias de seguridad para las instancias del cloud, teniendo en cuenta las siguientes características:
- Selecciona una aplicación para realizar el proceso: bacula, amanda, shell script con tar, rsync, dar, afio, etc.
- Utiliza una de las instancias como servidor de copias de seguridad, añadiéndole un volumen y almacenando localmente las copias de seguridad que consideres adecuadas en él.
- El proceso debe realizarse de forma completamente automática
- Selecciona qué información es necesaria guardar (listado de paquetes, ficheros de configuración, documentos, datos, etc.)
- Realiza semanalmente una copia completa
- Realiza diariamente una copia incremental o diferencial (decidir cual es más adecuada)
- Implementa una planificación del almacenamiento de copias de seguridad para una ejecución prevista de varios años, detallando qué copias completas se almacenarán de forma permanente y cuales se irán borrando
- Añade tu sistema de copias a coconut cuando esté disponible
- Selecciona un directorio de datos “críticos” que deberá almacenarse cifrado en la copia de seguridad, bien encargándote de hacer la copia manualmente o incluyendo la contraseña de cifrado en el sistema
- Incluye en la copia los datos de las nuevas aplicaciones que se vayan instalando durante el resto del curso
- Utiliza saturno u otra opción que se te facilite como equipo secundario para almacenar las copias de seguridad. Solicita acceso o la instalación de las aplicaciones que sean precisas.
La corrección consistirá tanto en la restauración puntual de un fichero en cualquier fecha como la restauración completa de una de las instancias la última semana de curso.
Instalación de mysql:
1
| debian@serranito:~$ sudo apt install mariadb-server mariadb-client
|
Instalación de bacula:
1
| debian@serranito:~$ sudo apt install bacula bacula-client bacula-common-mysql bacula-director-mysql bacula-server
|
Le damos a Si y ponemos la contraseña.
Vamos el fichero de configuración:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
| debian@serranito:~$ sudo nano /etc/bacula/bacula-dir.conf
Director {
Name = serranito-dir
DIRport = 9101
QueryFile = "/etc/bacula/scripts/query.sql"
WorkingDirectory = "/var/lib/bacula"
PidDirectory = "/run/bacula"
Maximum Concurrent Jobs = 20
Password = "ernestovazquez11"
Messages = Daemon
DirAddress = 10.0.0.8
}
JobDefs {
Name = "Tarea-Diaria"
Type = Backup
Level = Incremental
Client = serranito-fd
Schedule = "Programa-Diario"
Pool = Daily
Storage = Vol-Serranito
Messages = Standard
SpoolAttributes = yes
Priority = 10
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
JobDefs {
Name = "Tarea-Semanal"
Type = Backup
Client = serranito-fd
Schedule = "Programa-Semanal"
Pool = Weekly
Storage = Vol-Serranito
Messages = Standard
SpoolAttributes = yes
Priority = 10
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
JobDefs {
Name = "Tarea-Mensual"
Type = Backup
Client = serranito-fd
Schedule = "Programa-Mensual"
Pool = Monthly
Storage = Vol-Serranito
Messages = Standard
SpoolAttributes = yes
Priority = 10
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
Job {
Name = "Daily-Backup-Serranito"
JobDefs = "Tarea-Diaria"
Client = "serranito-fd"
FileSet= "Copia-Serranito"
}
Job {
Name = "Daily-Backup-Croqueta"
JobDefs = "Tarea-Diaria"
Client = "croqueta-fd"
FileSet= "Copia-Croqueta"
}
Job {
Name = "Daily-Backup-Tortilla"
JobDefs = "Tarea-Diaria"
Client = "tortilla-fd"
FileSet= "Copia-Tortilla"
}
Job {
Name = "Daily-Backup-Salmorejo"
JobDefs = "Tarea-Diaria"
Client = "salmorejo-fd"
FileSet= "Copia-Salmorejo"
}
Job {
Name = "Weekly-Backup-Serranito"
JobDefs = "Tarea-Semanal"
Client = "serranito-fd"
FileSet= "Copia-Serranito"
}
Job {
Name = "Weekly-Backup-Croqueta"
JobDefs = "Tarea-Semanal"
Client = "croqueta-fd"
FileSet= "Copia-Croqueta"
}
Job {
Name = "Weekly-Backup-Tortilla"
JobDefs = "Tarea-Semanal"
Client = "tortilla-fd"
FileSet= "Copia-Tortilla"
}
Job {
Name = "Weekly-Backup-Salmorejo"
JobDefs = "Tarea-Semanal"
Client = "salmorejo-fd"
FileSet= "Copia-Salmorejo"
}
Job {
Name = "Monthly-Backup-Serranito"
JobDefs = "Tarea-Mensual"
Client = "serranito-fd"
FileSet= "Copia-Serranito"
}
Job {
Name = "Monthly-Backup-Croqueta"
JobDefs = "Tarea-Mensual"
Client = "croqueta-fd"
FileSet= "Copia-Croqueta"
}
Job {
Name = "Monthly-Backup-Tortilla"
JobDefs = "Tarea-Mensual"
Client = "tortilla-fd"
FileSet= "Copia-Tortilla"
}
Job {
Name = "Monthly-Backup-Salmorejo"
JobDefs = "Tarea-Mensual"
Client = "salmorejo-fd"
FileSet= "Copia-Salmorejo"
}
Job {
Name = "Restore-Serranito"
Type = Restore
Client=serranito-fd
FileSet= "Copia-Serranito"
Storage = Vol-Serranito
Pool = Vol-Backup
Messages = Standard
}
Job {
Name = "Restore-Croqueta"
Type = Restore
Client=croqueta-fd
FileSet= "Copia-Croqueta"
Storage = Vol-Serranito
Pool = Vol-Backup
Messages = Standard
}
Job {
Name = "Restore-Tortilla"
Type = Restore
Client=tortilla-fd
FileSet= "Copia-Tortilla"
Storage = Vol-Serranito
Pool = Vol-Backup
Messages = Standard
}
Job {
Name = "Restore-Salmorejo"
Type = Restore
Client=salmorejo-fd
FileSet= "Copia-Salmorejo"
Storage = Vol-Serranito
Pool = Vol-Backup
Messages = Standard
}
FileSet {
Name = "Copia-Serranito"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /home
File = /etc
File = /var
File = /bacula
}
Exclude {
File = /nonexistant/path/to/file/archive/dir
File = /proc
File = /var/cache
File = /var/tmp
File = /tmp
File = /sys
File = /.journal
File = /.fsck
}
}
FileSet {
Name = "Copia-Croqueta"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /home
File = /etc
File = /var
}
Exclude {
File = /var/lib/bacula
File = /nonexistant/path/to/file/archive/dir
File = /proc
File = /var/tmp
File = /tmp
File = /sys
File = /.journal
File = /.fsck
}
}
FileSet {
Name = "Copia-Tortilla"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /home
File = /etc
File = /var
}
Exclude {
File = /var/lib/bacula
File = /nonexistant/path/to/file/archive/dir
File = /proc
File = /var/cache
File = /var/tmp
File = /tmp
File = /sys
File = /.journal
File = /.fsck
}
}
FileSet {
Name = "Copia-Salmorejo"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /home
File = /etc
File = /var
File = /usr/share/nginx
}
Exclude {
File = /var/lib/bacula
File = /nonexistant/path/to/file/archive/dir
File = /proc
File = /var/cache
File = /var/tmp
File = /tmp
File = /sys
File = /.journal
File = /.fsck
}
}
Schedule {
Name = "Programa-Diario"
Run = Level=Incremental Pool=Daily daily at 20:00
}
Schedule {
Name = "Programa-Semanal"
Run = Level=Full Pool=Weekly sat at 23:00
}
Schedule {
Name = "Programa-Mensual"
Run = Level=Full Pool=Monthly 1st sun at 23:00
}
Client {
Name = serranito-fd
Address = 10.0.0.8
FDPort = 9102
Catalog = mysql-bacula
Password = "ernestovazquez11"
File Retention = 90 days
Job Retention = 6 months
AutoPrune = yes
}
Client {
Name = croqueta-fd
Address = 10.0.0.10
FDPort = 9102
Catalog = mysql-bacula
Password = "ernestovazquez11"
File Retention = 90 days
Job Retention = 6 months
AutoPrune = yes
}
Client {
Name = tortilla-fd
Address = 10.0.0.4
FDPort = 9102
Catalog = mysql-bacula
Password = "ernestovazquez11"
File Retention = 90 days
Job Retention = 6 months
AutoPrune = yes
}
Client {
Name = salmorejo-fd
Address = 10.0.0.13
FDPort = 9102
Catalog = mysql-bacula
Password = "ernestovazquez11"
File Retention = 90 days
Job Retention = 6 months
AutoPrune = yes
}
Storage {
Name = Vol-Serranito
Address = 10.0.0.8
SDPort = 9103
Password = "ernestovazquez11"
Device = FileAutochanger1
Media Type = File
Maximum Concurrent Jobs = 10
}
Catalog {
Name = mysql-bacula
dbname = "bacula"; DB Address = "localhost"; dbuser = "bacula"; dbpassword = "ernestovazquez11"
}
Pool {
Name = Daily
# Use Volume Once = yes
Pool Type = Backup
AutoPrune = yes
VolumeRetention = 10d
Recycle = yes
}
Pool {
Name = Weekly
# Use Volume Once = yes
Pool Type = Backup
AutoPrune = yes
VolumeRetention = 30d
Recycle = yes
}
Pool {
Name = Monthly
# Use Volume Once = yes
Pool Type = Backup
AutoPrune = yes
VolumeRetention = 365d
Recycle = yes
}
Pool {
Name = Vol-Backup
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
Maximum Volume Bytes = 50G
Maximum Volumes = 100
Label Format = "Remoto"
}
# Reasonable message delivery -- send most everything to email address
# and to the console
Messages {
Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
# to replace the %r in the from field (-f part) with a single valid
# email address in both the mailcommand and the operatorcommand.
# What this does is, it sets the email address that emails would display
# in the FROM field, which is by default the same email as they're being
# sent to. However, if you send email to more than one address, then
# you'll have to set the FROM address manually, to a single address.
# for example, a 'no-reply@mydomain.com', is better since that tends to
# tell (most) people that its coming from an automated source.
#
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = root = all, !skipped
operator = root = mount
console = all, !skipped, !saved
#
# WARNING! the following will create a file that you must cycle from
# time to time as it will grow indefinitely. However, it will
# also keep all your messages if they scroll off the console.
#
append = "/var/log/bacula/bacula.log" = all, !skipped
catalog = all
}
#
# Message delivery for daemon messages (no job).
Messages {
Name = Daemon
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root = all, !skipped
console = all, !skipped, !saved
append = "/var/log/bacula/bacula.log" = all, !skipped
}
# Default pool definition
Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
}
# Scratch pool definition
Pool {
Name = Scratch
Pool Type = Backup
}
#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
Name = serranito-mon
Password = "6URHdHljsXACPlryk6so_xCbGqrmkYgFb"
CommandACL = status, .status
}
|
Vamos a configurar el volumen.
1
2
3
4
5
6
7
| debian@serranito:~$ lsblk -f
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
vda
└─vda1
ext4 6197e068-a892-45cb-9672-a05813e800ee 8G 14% /
vdb
|
Creamos una partición con:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| debian@serranito:~$ sudo fdisk /dev/vdb
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x73b8d268.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759):
Created a new partition 1 of type 'Linux' and of size 5 GiB.
Command (m for help): p
Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x73b8d268
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 10485759 10483712 5G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
|
La formateamos con:
1
2
3
4
5
6
7
8
9
10
11
12
| debian@serranito:~$ sudo mkfs.ext4 /dev/vdb1
mke2fs 1.44.5 (15-Dec-2018)
Creating filesystem with 1310464 4k blocks and 327680 inodes
Filesystem UUID: d65f629a-be7a-43a9-a93c-a5d2a507d8fc
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
|
Creamos el directorio para las copias y le cambiamos los permisos:
1
2
3
| debian@serranito:~$ sudo mkdir -p /bacula/Copias_de_Seguridad
debian@serranito:~$ sudo chown bacula:bacula /bacula -R
debian@serranito:~$ sudo chmod 755 /bacula -R
|
Necesitaremos el identificador siguiente para el fichero /etc/fstab
.
1
2
3
4
5
| debian@serranito:~$ lsblk -f | egrep "vdb1 *"
└─vdb1 ext4 d65f629a-be7a-43a9-a93c-a5d2a507d8fc
debian@serranito:~$ sudo nano /etc/fstab
UUID=d65f629a-be7a-43a9-a93c-a5d2a507d8fc /bacula/Copias_de_Seguridad ext4 defaults 0 0
|
1
2
3
4
5
6
| debian@serranito:~$ lsblk -l
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 254:0 0 10G 0 disk
vda1 254:1 0 10G 0 part /
vdb 254:16 0 5G 0 disk
vdb1 254:17 0 5G 0 part /bacula/Copias_de_Seguridad
|
Vamos a configurar el otro fichero de configuración bacula-sd.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| debian@serranito:~$ sudo nano /etc/bacula/bacula-sd.conf
Storage {
Name = serranito-sd
SDPort = 9103
WorkingDirectory = "/var/lib/bacula"
Pid Directory = "/run/bacula"
Maximum Concurrent Jobs = 20
SDAddress = 10.0.0.8
}
Director {
Name = serranito-dir
Password = "ernestovazquez11"
}
Director {
Name = serranito-mon
Password = "bacula"
Monitor = yes
}
Autochanger {
Name = FileAutochanger1
Device = DispositivoCopia
Changer Command = ""
Changer Device = /dev/null
}
Device {
Name = DispositivoCopia
Media Type = File
Archive Device = /bacula/Copias_de_Seguridad
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
Maximum Concurrent Jobs = 5
}
Messages {
Name = Standard
director = serranito-dir = all
}
|
Editamos el siguiente fichero:
1
2
3
4
5
6
7
8
| debian@serranito:~$ sudo nano /etc/bacula/bconsole.conf
Director {
Name = serranito-dir
DIRport = 9101
address = 10.0.0.8
Password = "ernestovazquez11"
}
|
Instalamos los clientes de bacula:
1
2
3
4
| debian@croqueta:~$ sudo apt install bacula-client
ubuntu@tortilla:~$ sudo apt install bacula-client
debian@serranito:~$ sudo apt install bacula-client
[root@salmorejo ~]# sudo dnf -y install bacula-client
|
A continuación pondremos la configuración en el siguiente fichero:
Este paso lo haremos en croqueta, tortilla y serranito.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| debian@croqueta:~$ sudo nano /etc/bacula/bacula-fd.conf
Director {
Name = serranito-dir
Password = "ernestovazquez11"
}
Director {
Name = serranito-mon
Password = "ernestovazquez11"
Monitor = yes
}
FileDaemon {
Name = croqueta-fd
FDport = 9102
WorkingDirectory = /var/lib/bacula
Pid Directory = /run/bacula
Maximum Concurrent Jobs = 20
Plugin Directory = /usr/lib/bacula
FDAddress = 10.0.0.10
}
Messages {
Name = Standard
director = serranito-dir = all, !skipped, !restored
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| [centos@salmorejo ~]$ sudo nano /etc/bacula/bacula-fd.conf
Director {
Name = serranito-dir
Password = "ernestovazquez11"
}
Director {
Name = serranito-mon
Password = "ernestovazquez11"
Monitor = yes
}
FileDaemon {
Name = salmorejo-fd
FDport = 9102
WorkingDirectory = /var/spool/bacula
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
Plugin Directory = /usr/lib64/bacula
}
Messages {
Name = Standard
director = serranito-dir = all, !skipped, !restored
}
|
Reinciamos los servicios:
1
2
3
4
| debian@serranito:~$ sudo systemctl restart bacula-fd.service
debian@croqueta:~$ sudo systemctl restart bacula-fd.service
ubuntu@tortilla:~$ sudo systemctl restart bacula-fd.service
[root@salmorejo ~]# sudo systemctl restart bacula-fd.service
|
Reiniciamos servicios del servidor en serranito:
1
2
| debian@serranito:~$ sudo systemctl restart bacula-sd.service
debian@serranito:~$ sudo systemctl restart bacula-director.service
|
Abrimos los puertos 9102/TCP en Openstack
Puertos en salmorejo:
1
2
| [root@salmorejo ~]# firewall-cmd --zone=public --permanent --add-port 9102/tcp
[root@salmorejo ~]# firewall-cmd --reload
|
Cambios para el funcionamiento:
Tenemos que quitar la siguiente linea del fichero de configuración del director:
1
2
3
| debian@serranito:~$ sudo nano /etc/bacula/bacula-dir.conf
Use Volume Once = yes
|
A continuación vamos a realizar una prueba con el siguiente comando:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| *run
Using Catalog "mysql-bacula"
A job name must be specified.
The defined Job resources are:
1: Daily-Backup-Serranito
2: Daily-Backup-Croqueta
3: Daily-Backup-Tortilla
4: Daily-Backup-Salmorejo
5: Weekly-Backup-Serranito
6: Weekly-Backup-Croqueta
7: Weekly-Backup-Tortilla
8: Weekly-Backup-Salmorejo
9: Monthly-Backup-Serranito
10: Monthly-Backup-Croqueta
11: Monthly-Backup-Tortilla
12: Monthly-Backup-Salmorejo
13: Restore-Serranito
14: Restore-Croqueta
15: Restore-Tortilla
16: Restore-Salmorejo
Select Job resource (1-16): 2
Run Backup job
JobName: Daily-Backup-Croqueta
Level: Incremental
Client: croqueta-fd
FileSet: Copia-Croqueta
Pool: Daily (From Job resource)
Storage: Vol-Serranito (From Job resource)
When: 2020-01-24 08:15:11
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=6
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| *status client
The defined Client resources are:
1: serranito-fd
2: croqueta-fd
3: tortilla-fd
4: salmorejo-fd
Select Client (File daemon) resource (1-4): 2
Connecting to Client croqueta-fd at 10.0.0.10:9102
croqueta-fd Version: 9.4.2 (04 February 2019) x86_64-pc-linux-gnu debian buster/sid
Daemon started 23-Jan-20 17:22. Jobs: run=1 running=0.
Heap: heap=114,688 smbytes=164,827 max_bytes=371,949 bufs=125 max_bufs=140
Sizes: boffset_t=8 size_t=8 debug=0 trace=0 mode=0,0 bwlimit=0kB/s
Plugin: bpipe-fd.so
Running Jobs:
JobId 6 Job Daily-Backup-Croqueta.2020-01-24_08.15.15_03 is running.
Full Backup Job started: 24-Jan-20 08:15
Files=0 Bytes=0 AveBytes/sec=0 LastBytes/sec=0 Errors=0
Bwlimit=0 ReadBytes=0
Files: Examined=0 Backed up=0
SDReadSeqNo=6 fd=5 SDtls=0
Director connected at: 24-Jan-20 08:15
====
|
Ahora vamos a configurar los labels
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| *label
Automatically selected Catalog: mysql-bacula
Using Catalog "mysql-bacula"
Automatically selected Storage: Vol-Serranito
Enter new Volume name: copiadiaria
Defined Pools:
1: Daily
2: Default
3: File
4: Monthly
5: Scratch
6: Vol-Backup
7: Weekly
Select the Pool (1-7): 1
Connecting to Storage daemon Vol-Serranito at 10.0.0.8:9103 ...
Sending label command for Volume "copiadiaria" Slot 0 ...
3000 OK label. VolBytes=225 VolABytes=0 VolType=1 Volume="copiadiaria" Device="DispositivoCopia" (/bacula/Copias_de_Seguridad)
Catalog record for Volume "copiadiaria", Slot 0 successfully created.
Requesting to mount FileAutochanger1 ...
3001 OK mount requested. Device="DispositivoCopia" (/bacula/Copias_de_Seguridad)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| *label
Automatically selected Storage: Vol-Serranito
Enter new Volume name: copiasemanal
Defined Pools:
1: Daily
2: Default
3: File
4: Monthly
5: Scratch
6: Vol-Backup
7: Weekly
Select the Pool (1-7): 7
Connecting to Storage daemon Vol-Serranito at 10.0.0.8:9103 ...
Sending label command for Volume "copiasemanal" Slot 0 ...
3000 OK label. VolBytes=227 VolABytes=0 VolType=1 Volume="copiasemanal" Device="DispositivoCopia" (/bacula/Copias_de_Seguridad)
Catalog record for Volume "copiasemanal", Slot 0 successfully created.
Requesting to mount FileAutochanger1 ...
3906 File device ""DispositivoCopia" (/bacula/Copias_de_Seguridad)" is always mounted.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| *label
Automatically selected Storage: Vol-Serranito
Enter new Volume name: copiamensual
Defined Pools:
1: Daily
2: Default
3: File
4: Monthly
5: Scratch
6: Vol-Backup
7: Weekly
Select the Pool (1-7): 4
Connecting to Storage daemon Vol-Serranito at 10.0.0.8:9103 ...
Sending label command for Volume "copiamensual" Slot 0 ...
3000 OK label. VolBytes=228 VolABytes=0 VolType=1 Volume="copiamensual" Device="DispositivoCopia" (/bacula/Copias_de_Seguridad)
Catalog record for Volume "copiamensual", Slot 0 successfully created.
Requesting to mount FileAutochanger1 ...
3906 File device ""DispositivoCopia" (/bacula/Copias_de_Seguridad)" is always mounted.
|
Ahora ya estarán las copias en funcionamiento como podemos ver a continuación:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| *status client
The defined Client resources are:
1: serranito-fd
2: croqueta-fd
3: tortilla-fd
4: salmorejo-fd
Select Client (File daemon) resource (1-4): 2
Connecting to Client croqueta-fd at 10.0.0.10:9102
croqueta-fd Version: 9.4.2 (04 February 2019) x86_64-pc-linux-gnu debian buster/sid
Daemon started 23-Jan-20 17:22. Jobs: run=2 running=0.
Heap: heap=114,688 smbytes=283,225 max_bytes=531,545 bufs=95 max_bufs=149
Sizes: boffset_t=8 size_t=8 debug=0 trace=0 mode=0,0 bwlimit=0kB/s
Plugin: bpipe-fd.so
Running Jobs:
Director connected at: 24-Jan-20 08:26
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
===================================================================
6 Full 3,265 66.46 M OK 24-Jan-20 08:18 Daily-Backup-Croqueta
====
You have messages.
|
En este punto me he quedado sin espacio en el disco para ello vamos a hacer una extensión en el cloud.
1
2
3
4
5
6
7
8
9
10
| debian@serranito:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 0 487M 0% /dev
tmpfs 99M 12M 88M 12% /run
/dev/vda1 9.9G 2.5G 7.0G 26% /
tmpfs 495M 0 495M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 495M 0 495M 0% /sys/fs/cgroup
/dev/vdb1 4.9G 4.6G 0 100% /bacula/Copias_de_Seguridad
tmpfs 99M 0 99M 0% /run/user/1000
|
Despues de aumentar el disco:
1
2
3
4
5
6
7
8
9
10
| debian@serranito:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 0 487M 0% /dev
tmpfs 99M 4.1M 95M 5% /run
/dev/vda1 9.9G 2.5G 7.0G 26% /
tmpfs 495M 0 495M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 495M 0 495M 0% /sys/fs/cgroup
tmpfs 99M 0 99M 0% /run/user/1000
/dev/vdb1 15G 579M 14G 5% /bacula/Copias_de_Seguridad
|
Tras reiniciar ya se están realizando las copias correctamentes. El problema es que Bacula no reconocia la nueva extensión del disco que hemos realizado previamente, he reiniciado los servicios de bacula y realizando de nuevo el label.
1
2
3
4
5
6
| Realizamos un list jobs:
| 96 | Daily-Backup-Serranito | 2020-02-10 11:06:10 | B | F | 3,746 | 320,857,078 | T |
| 97 | Daily-Backup-Croqueta | 2020-02-10 11:09:10 | B | F | 3,683 | 258,326,561 | T |
| 98 | Daily-Backup-Tortilla | 2020-02-10 11:59:17 | B | F | 5,149 | 67,566,160 | T |
| 99 | Daily-Backup-Salmorejo | 2020-02-10 11:59:24 | B | F | 45,936 | 396,294,638 | T |
|
Copia de paquetes
Por último vamos a realizar un script para guardar los paquetes instalados.
1
2
3
| debian@serranito:~$ sudo mkdir /var/script
debian@serranito:~$ sudo touch /var/script/paquetesinstalados.txt
debian@serranito:~$ sudo touch /var/script/paquetes.sh
|
Script:
1
2
3
| #!/bin/bash
sudo dpkg --get-selections > /var/script/paquetesinstalados.txt
|
Este script lo debemos de realizar en las máquinas croqueta, tortilla y serranito.
Permisos:
1
2
| debian@serranito:~$ sudo chown root:root /var/script/paquetes.sh
debian@serranito:~$ sudo chmod 744 /var/script/paquetes.sh
|
1
2
3
| debian@serranito:~$ sudo crontab -e
30 19 * * * /var/script/paquetes.sh
|
Y por último reiniciamos los servicios:
1
| debian@serranito:~$ sudo systemctl restart cron
|
Ahora vamos a ver como se configura en salmorejo.
1
2
3
| [centos@salmorejo ~]$ sudo mkdir /var/script
[centos@salmorejo ~]$ sudo touch /var/script/paquetesinstalados.txt
[centos@salmorejo ~]$ sudo touch /var/script/paquetes.sh
|
1
2
3
4
5
6
7
| [centos@salmorejo ~]$ sudo nano /var/script/paquetes.sh
#!/bin/bash
sudo rm /var/script/paquetesinstalados.txt
sudo touch /var/script/paquetesinstalados.txt
sudo rpm -qa > /var/script/paquetesinstalados.txt
|
Permisos:
1
2
| [centos@salmorejo ~]$ sudo chown root:root /var/script/paquetes.sh
[centos@salmorejo ~]$ sudo chmod 744 /var/script/paquetes.sh
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [centos@salmorejo ~]$ sudo nano /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
30 19 * * * root /var/script/paquetes.sh
|
1
| [centos@salmorejo ~]$ sudo systemctl restart crond
|
Restaurar los paquetes
Para restaurar los paquetes que acabamos de guardar solamente tendremos que hacer lo siguiente:
1
2
3
| debian@serranito:~$ sudo apt install dselect
debian@serranito:~$ sudo dpkg --set-selections < /var/script/paquetesinstalados.txt
debian@serranito:~$ sudo dselect
|
Con estos simples pasos podremos tener los mismos paquetes que teniamos antes junto con la copia de seguridad.