Created: 19 December 2008
インストールする
Fedora9では、yum でインストールできました。
# yum install bacula-*
データベースの作成
スクリプトが用意されているので、PostgreSQLの場合、以下のように実行します。
# su - postgres -bash-3.2$ /usr/libexec/bacula/create_bacula_database.postgresql
Creating PostgreSQL database
CREATE DATABASE
ALTER DATABASE
Creation of bacula database succeeded.
-bash-3.2$ /usr/libexec/bacula/make_bacula_tables.postgresql
Making PostgreSQL tables
psql:<stdin>:7: NOTICE: CREATE TABLE will create implicit sequence "filename_filenameid_seq" for serial column "filename.filenameid"
psql:<stdin>:7: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "filename_pkey" for table "filename"
CREATE TABLE
CREATE INDEX
psql:<stdin>:16: NOTICE: CREATE TABLE will create implicit sequence "path_pathid_seq" for serial column "path.pathid"
psql:<stdin>:16: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "path_pkey" for table "path"
CREATE TABLE
CREATE INDEX
psql:<stdin>:31: NOTICE: CREATE TABLE will create implicit sequence "file_fileid_seq" for serial column "file.fileid"
psql:<stdin>:31: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "file_pkey" for table "file"
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:<stdin>:70: NOTICE: CREATE TABLE will create implicit sequence "job_jobid_seq" for serial column "job.jobid"
psql:<stdin>:70: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "job_pkey" for table "job"
CREATE TABLE
CREATE INDEX
psql:<stdin>:80: NOTICE: CREATE TABLE will create implicit sequence "location_locationid_seq" for serial column "location.locationid"
psql:<stdin>:80: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "location_pkey" for table "location"
CREATE TABLE
psql:<stdin>:90: NOTICE: CREATE TABLE will create implicit sequence "fileset_filesetid_seq" for serial column "fileset.filesetid"
psql:<stdin>:90: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "fileset_pkey" for table "fileset"
CREATE TABLE
CREATE INDEX
psql:<stdin>:108: NOTICE: CREATE TABLE will create implicit sequence "jobmedia_jobmediaid_seq" for serial column "jobmedia.jobmediaid"
psql:<stdin>:108: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "jobmedia_pkey" for table "jobmedia"
CREATE TABLE
CREATE INDEX
psql:<stdin>:159: NOTICE: CREATE TABLE will create implicit sequence "media_mediaid_seq" for serial column "media.mediaid"
psql:<stdin>:159: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "media_pkey" for table "media"
CREATE TABLE
CREATE INDEX
psql:<stdin>:169: NOTICE: CREATE TABLE will create implicit sequence "mediatype_mediatypeid_seq" for serial column "mediatype.mediatypeid"
psql:<stdin>:169: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "mediatype_pkey" for table "mediatype"
CREATE TABLE
psql:<stdin>:176: NOTICE: CREATE TABLE will create implicit sequence "storage_storageid_seq" for serial column "storage.storageid"
psql:<stdin>:176: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "storage_pkey" for table "storage"
CREATE TABLE
psql:<stdin>:195: NOTICE: CREATE TABLE will create implicit sequence "device_deviceid_seq" for serial column "device.deviceid"
psql:<stdin>:195: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "device_pkey" for table "device"
CREATE TABLE
psql:<stdin>:226: NOTICE: CREATE TABLE will create implicit sequence "pool_poolid_seq" for serial column "pool.poolid"
psql:<stdin>:226: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pool_pkey" for table "pool"
CREATE TABLE
CREATE INDEX
psql:<stdin>:239: NOTICE: CREATE TABLE will create implicit sequence "client_clientid_seq" for serial column "client.clientid"
psql:<stdin>:239: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "client_pkey" for table "client"
CREATE TABLE
CREATE INDEX
psql:<stdin>:250: NOTICE: CREATE TABLE will create implicit sequence "log_logid_seq" for serial column "log.logid"
psql:<stdin>:250: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "log_pkey" for table "log"
CREATE TABLE
CREATE INDEX
psql:<stdin>:265: NOTICE: CREATE TABLE will create implicit sequence "locationlog_loclogid_seq" for serial column "locationlog.loclogid"
psql:<stdin>:265: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "locationlog_pkey" for table "locationlog"
CREATE TABLE
psql:<stdin>:277: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "counters_pkey" for table "counters"
CREATE TABLE
psql:<stdin>:289: NOTICE: CREATE TABLE will create implicit sequence "basefiles_baseid_seq" for serial column "basefiles.baseid"
psql:<stdin>:289: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "basefiles_pkey" for table "basefiles"
CREATE TABLE
psql:<stdin>:298: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unsavedfiles_pkey" for table "unsavedfiles"
CREATE TABLE
psql:<stdin>:305: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "cdimages_pkey" for table "cdimages"
CREATE TABLE
CREATE TABLE
psql:<stdin>:317: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "status_pkey" for table "status"
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
Creation of Bacula PostgreSQL tables succeeded.
-bash-3.2$ /usr/libexec/bacula/grant_bacula_privileges.postgresql
Granting PostgreSQL privileges
CREATE ROLE
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
Privileges for bacula granted on bacula.
-bash-3.2$
Directorデーモンの設定と起動
"/etc/bacula/bacula-dir.conf "に設定します。
Director {
Name = bacula-dir
DIRport = 9101
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/var/spool/bacula"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "bacula"
Messages = Daemon
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = bacula-fd
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = Default
Priority = 10
}
Job {
Name = "Client1"
JobDefs = "DefaultJob"
Write Bootstrap = "/var/spool/bacula/Client1.bsr"
}
Job {
Name = "BackupCatalog"
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
# This creates an ASCII copy of the catalog
RunBeforeJob = "/usr/libexec/bacula/make_catalog_backup bacula bacula"
# This deletes the copy of the catalog
RunAfterJob = "/usr/libexec/bacula/delete_catalog_backup"
Write Bootstrap = "/var/spool/bacula/BackupCatalog.bsr"
Priority = 11
}
Job {
Name = "RestoreFiles"
Type = Restore
Client=bacula-fd
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /tmp/bacula-restores
}
# List of files to be backed up
FileSet {
Name = "Full Set"
Include {
Options {
signature = MD5
}
File = /backup
}
Exclude {
File = /proc
File = /tmp
File = /.journal
File = /.fsck
}
}
Schedule {
Name = "WeeklyCycle"
Run = Full 1st sun at 23:05
Run = Differential 2nd-5th sun at 23:05
Run = Incremental mon-sat at 23:05
}
# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
Name = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 23:10
}
# This is the backup of the catalog
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = /var/spool/bacula/bacula.sql
}
}
# Client (File Services) to backup
Client {
Name = bacula-fd
Address = 192.168.83.106
FDPort = 9102
Catalog = MyCatalog
Password = "bacula"
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}
# Definition of file storage device
Storage {
Name = File
# Do not use "localhost" here
Address = 192.168.83.106
SDPort = 9103
Password = "bacula"
Device = FileStorage
Media Type = File
}
# Generic catalog service
Catalog {
Name = MyCatalog
dbname = bacula; user = bacula; password = ""
}
# Reasonable message delivery -- send most everything to email address
# and to the console
Messages {
Name = Standard
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@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/var/spool/bacula/log" = all, !skipped
}
# 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@localhost = all, !skipped
console = all, !skipped, !saved
append = "/var/log/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
}
起動してみる
# service bacula-dir start
Storageデーモンの設定と起動
Storage {
Name = bacula-sd
SDPort = 9103
WorkingDirectory = "/var/spool/bacula"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
Director {
Name = bacula-dir
Password = "bacula"
}
Device {
Name = FileStorage
Media Type = File
Archive Device = /backup
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}
起動してみる
# service bacula-sd start
Fileデーモンの設定と起動
Director {
Name = bacula-dir
Password = "bacula"
}
Director {
Name = bacula-mon
Password = "bacula"
Monitor = yes
}
FileDaemon {
Name = bacula-fd
FDport = 9102
WorkingDirectory = /var/spool/bacula
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
Messages {
Name = Standard
director = bacula-dir = all, !skipped, !restored
}
起動してみる
# service bacula-sd start
コンソールの起動
"/etc/bacula/bconsole.conf "を設定します。
Director {
Name = bacula-dir
DIRport = 9101
address = 192.168.83.106
Password = "bacula"
}
起動してみる
# bconsole
Connecting to Director 192.168.83.106:9101
1000 OK: bacula-dir Version: 2.2.8 (26 January 2008)
Enter a period to cancel a command.
*
バックアップを実行してみる
# bconsole
Connecting to Director 192.168.83.106:9101
1000 OK: bacula-dir Version: 2.2.8 (26 January 2008)
Enter a period to cancel a command.
*label
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Automatically selected Storage: File
Enter new Volume name: TEST
Automatically selected Pool: Default
Connecting to Storage daemon File at 192.168.83.106:9103 ...
Sending label command for Volume "TEST" Slot 0 ...
3000 OK label. VolBytes=205 DVD=0 Volume="TEST" Device="FileStorage" (/backup)
Catalog record for Volume "TEST", Slot 0 successfully created.
Requesting to mount FileStorage ...
3906 File device "FileStorage" (/backup) is always mounted.
*run
A job name must be specified.
Automatically selected Job: Client1
Run Backup job
JobName: Client1
Level: Incremental
Client: bacula-fd
FileSet: Full Set
Pool: Default (From Job resource)
Storage: File (From Job resource)
When: 2008-12-20 19:36:32
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: When
7: Priority
8: Pool
Select parameter to modify (1-8): 1
Levels:
1: Base
2: Full
3: Incremental
4: Differential
5: Since
Select level (1-5): 2
Run Backup job
JobName: Client1
Level: Full
Client: bacula-fd
FileSet: Full Set
Pool: Default (From Job resource)
Storage: File (From Job resource)
When: 2008-12-20 19:36:32
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=4
*status
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3
Automatically selected Client: bacula-fd
Connecting to Client bacula-fd at 192.168.83.106:9102
bacula-fd Version: 2.2.8 (26 January 2008) i386-redhat-linux-gnu redhat
Daemon started 20-12008 19:16, 1 Job run since started.
Heap: heap=520,192 smbytes=77,927 max_bytes=147,230 bufs=56 max_bufs=84
Sizeof: boffset_t=8 size_t=4 debug=0 trace=0
Running Jobs:
Director connected at: 20-12008 19:36
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
======================================================================
4 Full 4 3.576 K OK 20-12008 19:36 Client1
====
You have messages.
*status
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3
Automatically selected Client: bacula-fd
Connecting to Client bacula-fd at 192.168.83.106:9102
bacula-fd Version: 2.2.8 (26 January 2008) i386-redhat-linux-gnu redhat
Daemon started 20-12008 19:16, 1 Job run since started.
Heap: heap=520,192 smbytes=77,927 max_bytes=147,230 bufs=56 max_bufs=84
Sizeof: boffset_t=8 size_t=4 debug=0 trace=0
Running Jobs:
Director connected at: 20-12008 19:37
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
======================================================================
4 Full 4 3.576 K OK 20-12008 19:36 Client1
====
*exit
#