NRW:Arbeitsgruppe/Technik/Dokumentation/Backup
Dienste: E-Mail | Lists | Blogs | Domains | RT | Mumble | LAN | Serverstatus
Inhaltsverzeichnis
Programme
Es gibt 2 Programme für die Steuerung von Bacula. Ein Comandozeilenorientieres (bconsole) und ein Graphisches (bat). Zunächst einmal deren Einrichtung:
bconsole
Auf backup befindet sich ein fertig eingerichtetes bconsole. Wer dort Zugriff hat kann sich einfach einloggen und bconsole starten.
- Um bconsole auf seinem eigenen Recher zu installieren:
- apt-get install bacula-console
- vpn mit Sicht auf backup muss an sein.
- /etc/bacula/bconsole.conf von backup kopieren.
- >bconsole -c ./bconsole.conf
- fertig!
bat
Bat geht (da auf backup kein X läuft) nur auf dem eigenen Rechner.
- Um bat zu installieren:
- apt-get install bacula-console-qt
- vpn mit Sicht auf backup muss an sein.
- /root/bat.conf von backup kopieren.
- bat -c ./bat.conf
- fertig!
Als nächstes beschreibe ich einige Standardabläufe. Frei nach dem Prinzip: "Keiner will Backup aber alle wollen restore" fange ich mal mit letzerem an.
Restore
Restore von Files oder Verzeichnissen.
bconsole
>bconsole
*restore
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.
To select the JobIds, you have the following choices:
1: List last 20 Jobs run
2: List Jobs where a given File is saved
3: Enter list of comma separated JobIds to select
4: Enter SQL list command
5: Select the most recent backup for a client
6: Select backup for a client before a specified time
7: Enter a list of files to restore
8: Enter a list of files to restore before a specified time
9: Find the JobIds of the most recent backup for a client
10: Find the JobIds for a backup for a client before a specified time
11: Enter a list of directories to restore for found JobIds
12: Select full restore to a specified Job date
13: Cancel
Select item: (1-13): 5
Defined Clients:
1: access-piratennrw-fd
2: applejack-piratennrw-fd
3: backup-piratennrw-fd
4: blog-piratennrw-fd
5: bunker-piratennrw-fd
6: esbrennt-piratennrw-fd
7: fraktion-piratennrw-fd
8: helpdesk-piratennrw-fd
9: kalender-piratennrw-fd
10: lists-piratennrw-fd
11: lpt-dev-piratennrw-fd
12: mail-piratennrw-fd
13: map-piratennrw-fd
14: monitoring-piratennrw-fd
15: mumble-piratennrw-fd
16: pad-piratennrw-fd
17: rainbowdash-piratennrw-fd
18: verwaltung-piratennrw-fd
19: vorstand-piratennrw-fd
20: wikimirror-piratennrw-fd
21: www-piratennrw-fd
22: wwwcache-piratennrw-fd
Select the Client (1-22): 15
Automatically selected FileSet: Full Set Client
+-------+-------+----------+-------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |
+-------+-------+----------+-------------+---------------------+------------+
| 945 | F | 40,147 | 927,652,983 | 2012-09-02 04:52:03 | Full-0296 |
| 1,253 | D | 391 | 210,297,510 | 2012-09-16 03:39:33 | Diff-0249 |
| 1,267 | I | 218 | 187,463,121 | 2012-09-17 03:09:12 | Incr-0201 |
| 1,275 | I | 218 | 187,472,891 | 2012-09-17 03:30:55 | Incr-0282 |
| 1,289 | I | 170 | 118,759,645 | 2012-09-18 03:07:58 | Incr-0216 |
| 1,297 | I | 170 | 118,764,114 | 2012-09-18 03:24:46 | Incr-0224 |
+-------+-------+----------+-------------+---------------------+------------+
You have selected the following JobIds: 945,1253,1267,1275,1289,1297
Building directory tree for JobId(s) 945,1253,1267,1275,1289,1297 ...
+++++++++++++++++++++++++++++++++++++++++++++
36,334 files inserted into the tree.
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
cwd is: /
$ help
Command Description
======= ===========
add add dir/file to be restored recursively, wildcards allowed
cd change current directory
count count marked files in and below the cd
delete delete dir/file to be restored recursively in dir
dir long list current directory, wildcards allowed
done leave file selection mode
estimate estimate restore size
exit same as done command
find find files, wildcards allowed
help print help
ls list current directory, wildcards allowed
lsmark list the marked files in and below the cd
mark mark dir/file to be restored recursively, wildcards allowed
markdir mark directory name to be restored (no files)
pwd print current working directory
unmark unmark dir/file to be restored recursively in dir
unmarkdir unmark directory name only no recursion
quit quit and do not do restore
? print help
$ cd etc
cwd is: /etc/
$ add hosts
1 file marked.
$ done
Bootstrap records written to /var/lib/bacula/backup-piratennrw-dir.restore.1.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
Full-0296 File FileStorage
Volumes marked with "*" are online.
1 file selected to be restored.
Run Restore job
JobName: RestoreFiles
Bootstrap: /var/lib/bacula/backup-piratennrw-dir.restore.1.bsr
Where: /mnt/qnap/bacula
Replace: always
FileSet: Full Set Client
Backup Client: mumble-piratennrw-fd
Restore Client: mumble-piratennrw-fd
Storage: File
When: 2012-09-18 23:12:26
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): no
Job not run.
*
bat
FIXME
Einrichten eines neuen Client
Installieren eines bacula-client auf neuer VM
- apt-get install bacula-client
- edit /etc/bacula/bacula-client.conf (alles in spitzen Klammern bearbeiten):
# Bacula File Daemon Configuration file
#
# For Bacula release 5.0.2 (28 April 2010) -- debian squeeze/sid
Director {
Name = backup-piratennrw-dir
Password = "<fettes Passwort>"
}
# Restricted Director, used by tray-monitor
Director {
Name = <VMname>-piratennrw-mon
Password = "<fettes Monitor Passwort>"
Monitor = yes
}
FileDaemon {
Name = <VMname>-piratennrw-fd
FDAddress = 192.168.42.<IP>
FDport = 9102
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run/bacula
Maximum Concurrent Jobs = 20
}
Messages {
Name = Standard
director = backup-piratennrw-dir = all, !skipped, !restored
}
- Passworte zur Doku auf backup in /root/bacula-passwords eintragen.
- service bacula-client restart
- falls mysql oder postgresql Datenbanken vorhanden sind:
- copy /root/backupdbs von backup nach /usr/local/sbin/backupdbs auf dem client
- chmod 550 /usr/local/sbin/backupdbs
- edit /root/.my.cnf anlegen mit folgendem Inhalt:
[client] user=root password=<mysql-password> protocol=tcp
- chmod 400 /root/.my.cnf
- bei postgresql: TODO (map ist die erste maschine mit postgresql)
- testen ob backup-script richtig durch läuft durch starten des sript von Hand.
- client fertig!
Eintragen eines neuen Client auf backup
- cd /etc/bacula/clientdefs/
- edit <VMname>.conf
# Client <VMname>.piratenpartei-nrw.de
Client {
Name = <VMname>-piratennrw-fd
Address = 192.168.42.<ip>
FDPort = 9102
Catalog = MyCatalog
Password = "<das fette Client Passwort>"
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}
Job {
Name = "Backup <VMname>"
JobDefs = "DefaultJobSql" # bei keiner DB Sql entfernen!
Client = <VMname>-piratennrw-fd
FileSet = "Full Set Client"
}
- service bacula-director restart
- fertig. Ab der nächsten Nacht wir die Maschine mit gesichert.
- wer es mag kann mit bconsole oder bat ein erstes Backup sofort anstoßen.
Aufbau des Backupsystems
Unser Backup läuft Filebasiert mit dem Bacula System www.bacula.org . Auf den Hosts und den VMs läuft ein Client der vom Director in der Backup-VM gesteuert wird. Die Maschinen werden so im laufenden Betrieb gesichert. Von den Datenbanken wird vor dem Backup per script ein Dump gezogen. Die Backups werden auf einer per iscsi angebundenen qnap gesichert. Die qnap ist in der backupVM gemounted unter /mnt/qnap Aktuelle Backupzeiten und Formen:
- täglich: um 3:05 Uhr incrementell aller Maschinen. Anschließend full des Catalogs.
- wöchentlich: um 3:05 Uhr am Sonntag differenziell aller Maschinen.
- monatlich: um 3:05 Uhr full aller Maschinen.
Vor- und Nachteile von bacula
- Vorteil: keine Unterbrechung des laufenden Betriebs. Kleine Backupfiles.
- Nachteil: hoher Arbeitsaufwand bei Ausfall einer ganzen VM oder des Servers.
TODO für Verbesserungen
- Einrichten eines VM-snapshot-Backup für backup selber (bringt starke Vereinfachung des restore bei Gesamtausfall). Kein Problem, da backup selber ja nicht 24/7 kritisch ist.
- backupVM remote aufbewahren und lokal starten können. Hift bei der Wiederherstellung der Proxmox-Hosts.
- postgresql scrip erstellen
- Vereinheitlichung der Client-Installs. Vereinfacht anlegen neuer VMs (alle Configs gleich machen und sql-Ja/Nein/Typ im script abfragen!)
- Verschlüsseln des Backup (kommt jetzt mit dem einbinden von bunker)
- ssl-Verschüsselung der Client-Server Verbindungen (erst akut notwendig wenn wir getrennte Systeme haben)
- iscsi startet aktuell noch zu spät. mounted noch nicht von alleine nach reboot. (aktuell ein manuelles 'mount /mnt/qnap' nach VM neustat nötig!)
- Doku verbessern ;-)
Fehler die man nur einmal macht
- Wenn das Backup des Bacula Catalogs fehlschlägt kann das an falsch gesetzten Rechten unter /etc/bacula liegen. Passiert leicht wenn man einen neuen Client hinzufügt. Dann hilft:
chown -R root:bacula /etc/bacula