paloma blog

NWエンジニアやってます。技術の備忘など。Pythonもちょっと。タイトルは好きなカクテルから。

Baculaでバックアップを取ってみる ubuntu client編

前回のバックアップから間が空いてしまいましたが別マシンのバックアップを挑戦します。

2台目クライアント追加

下記手順を参考に2台めのクライアント設定を追記します。

簡易版チュートリアル – Bacula

サーバ側

  • bacula-dir.conf

jobに2台目を追加。

# 1台目
Job {
  Name = "BackupClient1"
  JobDefs = "DefaultJob"
}

# 2台目
Job {
  Name = "BackupClient2"
  Client = PC-ubuntu-fd
  JobDefs = "DefaultJob"
}

clientも。

# 1台目
Client {
  Name = bacula-fd
  Address = localhost
  FDPort = 9102
  Catalog = MyCatalog
  Password = "bacula-fd"          # password for FileDaemon
  File Retention = 60 days            # 60 days
  Job Retention = 6 months            # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}

# 2台目
Client {
  Name = PC-ubuntu-fd
  Address = 192.168.0.10
  FDPort = 9102
  Catalog = MyCatalog
  Password = "bacula-fd"          # password for FileDaemon
  File Retention = 60 days            # 60 days
  Job Retention = 6 months            # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}  

Storageも修正

Autochanger {
  Name = File1
# Do not use "localhost" here
# Addressの行を外のサーバからもつつけるように外向けのIPに変更する
  Address = 192.168.0.12                # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "bacula-sd"
  Device = FileChgr1
  Media Type = File1
  Maximum Concurrent Jobs = 10        # run up to 10 jobs a the same time
  Autochanger = File1                 # point to ourself
}

クライアント側

  • ubuntu16.04 LTS デスクトップです。
  • bacula-clientをインストール。

9系は一部のパッケージがインストールできなかったため、標準のリポジトリからインストールします。

  • 9系のbuild手順

bacula.us

依存で入るdefault-libmysqlclient-devというパッケージが17.10からサポートされていないため、9系は諦めます。

Ubuntu – Package Search Results -- default-libmysqlclient-dev

masashi@PC-ubuntu:~$ sudo apt install bacula-client

7系がインストールされます。

masashi@PC-ubuntu:~$ dpkg -l | grep bacula
ii  bacula-client                               7.0.5+dfsg-4ubuntu0.1                        all          network backup service - client metapackage
ii  bacula-common                               7.0.5+dfsg-4ubuntu0.1                        amd64        network backup service - common support files
ii  bacula-console                              7.0.5+dfsg-4ubuntu0.1                        amd64        network backup service - text console
ii  bacula-fd                                   7.0.5+dfsg-4ubuntu0.1                        amd64        network backup service - file daemon
  • bacula-fd.conf
#
# List Directors who are permitted to contact this File daemon
#
Director {
  Name = bacula-dir 
  Password = "bacula-fd"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
#
Director {
  Name = 192.168.0.12 #bacula-dir と書くとconfigtestでエラーになる
  Password = "Bacula"
  Monitor = yes
}

#
# "Global" File daemon configuration specifications
#
FileDaemon {                          # this is me
  Name = PC-ubuntu-fd
  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /var/lib/bacula
  Pid Directory = /var/run/bacula
  Maximum Concurrent Jobs = 20
# Plugin Directory = /usr/lib/bacula
  FDAddress = 192.168.0.10 #127.0.0.1
}

それぞれサービスをrestart

  • 手順は割愛

サーバから接続してみます。

[root@bacula bacula]# bconsole
Connecting to Director localhost:9101
1000 OK: 103 bacula-dir Version: 9.0.6 (20 November 2017)
Enter a period to cancel a command.
*
*status client
The defined Client resources are:
     1: bacula-fd
     2: PC-ubuntu-fd
Select Client (File daemon) resource (1-2): 2
Connecting to Client PC-ubuntu-fd at 192.168.0.10:9102

PC-ubuntu-fd Version: 7.0.5 (28 July 2014)  x86_64-pc-linux-gnu ubuntu 16.04
Daemon started 14- 6��2018 01:08. Jobs: run=0 running=0.
 Heap: heap=143,360 smbytes=187,691 max_bytes=187,838 bufs=53 max_bufs=54
 Sizes: boffset_t=8 size_t=8 debug=0 trace=0 mode=0,0 bwlimit=0kB/s

Running Jobs:
Director connected at: 14- 6��2018 01:08
No Jobs running.
====

Terminated Jobs:
====
*
*

version7で見えてます。

runでバックアップします。

*run
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
     1: BackupClient1
     2: BackupClient2
     3: BackupCatalog
     4: RestoreFiles
Select Job resource (1-4): 2
Run Backup job
JobName:  BackupClient2
Level:    Incremental
Client:   PC-ubuntu-fd
FileSet:  Full Set
Pool:     File (From Job resource)
Storage:  File1 (From Job resource)
When:     2018-06-14 01:28:10
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=40
*

runningにならない…

*status dir
bacula-dir Version: 9.0.6 (20 November 2017) x86_64-redhat-linux-gnu redhat (Core)
Daemon started 14- 6��2018 01:23, conf reloaded 14- 6-2018 01:23:03
 Jobs: run=0, running=1 mode=0,0
 Heap: heap=270,336 smbytes=102,538 max_bytes=137,949 bufs=339 max_bufs=343
 Res: njobs=4 nclients=2 nstores=2 npools=3 ncats=1 nfsets=2 nscheds=2

Scheduled Jobs:
Level          Type     Pri  Scheduled          Job Name           Volume
===================================================================================
Incremental    Backup    10  14- 6��2018 23:05  BackupClient1      Vol-0019
Incremental    Backup    10  14- 6��2018 23:05  BackupClient2      Vol-0019
Full           Backup    11  14- 6��2018 23:10  BackupCatalog      Vol-0019
====

Running Jobs:
Console connected at 14- 6��2018 01:27
 JobId  Type Level     Files     Bytes  Name              Status
======================================================================
    40  Back Full          0         0  BackupClient2     is waiting for Client PC-ubuntu-fd to connect to Storage File1
====

Terminated Jobs:
 JobId  Level      Files    Bytes   Status   Finished        Name 
====================================================================
    19  Full           0         0   Error    02- 6��2018 23:05 JOB-Bacula-ubuntu
    20  Full           0         0   Error    02- 6��2018 23:05 BackupClient1
    21  Full           0         0   Error    02- 6��2018 23:10 BackupCatalog
    22  Full           0         0   Error    03- 6��2018 20:14 JOB-Bacula-ubuntu
    23  Full           0         0   Error    03- 6��2018 23:05 JOB-Bacula-ubuntu
    24  Full           0         0   Error    03- 6��2018 23:05 BackupClient1
    25  Full           0         0   Error    03- 6��2018 23:10 BackupCatalog
    26  Full           0         0   Error    04- 6��2018 23:05 JOB-Bacula-ubuntu
    27  Full           0         0   Error    04- 6��2018 23:05 BackupClient1
    28  Full           0         0   Error    04- 6��2018 23:10 BackupCatalog

====
*

もしやと思いfirewalldを止めたらrunningになりました。
後でポート開けないと。
(SELinuxは止めてたような。後で確認しよう)

[root@bacula ~]# systemctl stop firewalld
[root@bacula ~]# 
[root@bacula ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 木 2018-06-14 01:30:05 JST; 4s ago
     Docs: man:firewalld(1)
  Process: 658 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 658 (code=exited, status=0/SUCCESS)

 614 01:22:55 bacula systemd[1]: Starting firewalld - dynamic firewall daemon...
 614 01:22:58 bacula systemd[1]: Started firewalld - dynamic firewall daemon.
 614 01:30:05 bacula systemd[1]: Stopping firewalld - dynamic firewall daemon...
 614 01:30:05 bacula systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@bacula ~]# 
[root@bacula ~]# 
[root@bacula ~]# 
[root@bacula ~]# bconsole 
Connecting to Director localhost:9101
1000 OK: 103 bacula-dir Version: 9.0.6 (20 November 2017)
Enter a period to cancel a command.
*
You have messages.
*status dir
bacula-dir Version: 9.0.6 (20 November 2017) x86_64-redhat-linux-gnu redhat (Core)
Daemon started 14- 6��2018 01:23, conf reloaded 14- 6-2018 01:23:03
 Jobs: run=0, running=1 mode=0,0
 Heap: heap=270,336 smbytes=102,296 max_bytes=137,949 bufs=337 max_bufs=343
 Res: njobs=4 nclients=2 nstores=2 npools=3 ncats=1 nfsets=2 nscheds=2

Scheduled Jobs:
Level          Type     Pri  Scheduled          Job Name           Volume
===================================================================================
Incremental    Backup    10  14- 6��2018 23:05  BackupClient1      Vol-0019
Incremental    Backup    10  14- 6��2018 23:05  BackupClient2      Vol-0019
Full           Backup    11  14- 6��2018 23:10  BackupCatalog      Vol-0019
====

Running Jobs:
Console connected at 14- 6��2018 01:30
 JobId  Type Level     Files     Bytes  Name              Status
======================================================================
    40  Back Full          0         0  BackupClient2     is running
====

Terminated Jobs:
 JobId  Level      Files    Bytes   Status   Finished        Name 
====================================================================
    19  Full           0         0   Error    02- 6��2018 23:05 JOB-Bacula-ubuntu
    20  Full           0         0   Error    02- 6��2018 23:05 BackupClient1
    21  Full           0         0   Error    02- 6��2018 23:10 BackupCatalog
    22  Full           0         0   Error    03- 6��2018 20:14 JOB-Bacula-ubuntu
    23  Full           0         0   Error    03- 6��2018 23:05 JOB-Bacula-ubuntu
    24  Full           0         0   Error    03- 6��2018 23:05 BackupClient1
    25  Full           0         0   Error    03- 6��2018 23:10 BackupCatalog
    26  Full           0         0   Error    04- 6��2018 23:05 JOB-Bacula-ubuntu
    27  Full           0         0   Error    04- 6��2018 23:05 BackupClient1
    28  Full           0         0   Error    04- 6��2018 23:10 BackupCatalog

====
*

途中経過

このPCはデスクトップなのでそこそこサイズでかくなりそう。

Running Jobs:
Console connected at 14- 6��2018 01:30
 JobId  Type Level     Files     Bytes  Name              Status
======================================================================
    40  Back Full      9,806    567.7 M BackupClient2     is running
====

ここで事件発生

夜に仕掛けて朝確認しようと思ったんですが、起きたらBaculaサーバが停止していました…
外付けHDDにBaculaサーバの仮想マシンの保存領域があるのですが、このHDDが何故か電源が落ちていて最終的な結果が不明です。

実はbaculaの再起動時にエラーが出ていたので、この辺調べればなにかわかるかも。
サービス再起動に失敗するのでOSごと再起動して検証していました。

[root@bacula bacula]# systemctl restart bacula-dir.conf
Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: GDBus.Error:org.freedesktop.DBus.Error.TimedOut: Failed to activate service 'org.freedesktop.PolicyKit1': timed out (g-dbus-error-quark, 20)
Failed to restart bacula-dir.conf.service: 接続がタイムアウトしました
See system logs and 'systemctl status bacula-dir.conf.service' for details.
[root@bacula bacula]# 

とりあえずクライアント追加の手順もなんとなく出来たので、引き続きWindows機のバックアップもやりたいと思います。

その前にbaculaサーバの復旧か作りなおした方がいいかもですね。
HDDは電源入ったのですが、サーバがEmergency modeで起動しちゃってる…