Skip to content

Instantly share code, notes, and snippets.

@eclecticmiraclecat
Last active June 23, 2021 05:24
Show Gist options
  • Save eclecticmiraclecat/3b6b270fd91fa6cc28bd8e9d2a3bf4ae to your computer and use it in GitHub Desktop.
Save eclecticmiraclecat/3b6b270fd91fa6cc28bd8e9d2a3bf4ae to your computer and use it in GitHub Desktop.

task

  • copy contents of /var/www/html to /data

install

apt-get install bacula -y

create backup directory

mkdir /data
chown -R bacula:bacula /data

storage (sd conf)

cat /etc/bacula/bacula-sd.conf
Storage {                             # definition of myself
  Name = ubuntu-sd
  SDPort = 9103                  # Director's port
  WorkingDirectory = "/var/lib/bacula"
  Pid Directory = "/run/bacula"
  Plugin Directory = "/usr/lib/bacula"
  Maximum Concurrent Jobs = 20
  SDAddress = 127.0.0.1
}

Director {
  Name = ubuntu-dir
  Password = "WMYDtJXi2aqlU8ReuoUPUVkg6ny0yqgYF"
}

Director {
  Name = ubuntu-mon
  Password = "oHVj7JOvgEgnHvYfwrP2sAfkoacXTK2cq"
  Monitor = yes
}

Messages {
  Name = Standard
  director = ubuntu-dir = all
}

Device {
  Name = Local-device
  Media Type = File
  Archive Device = /data
  LabelMedia = yes; # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes; # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

test config

bacula-sd -tc /etc/bacula/bacula-sd.conf

start and and enable Bacula

systemctl start bacula-sd
systemctl enable bacula-sd

director (dir conf)

cat /etc/bacula/bacula-dir.conf
Director {                            # define myself
  Name = ubuntu-dir
  DIRport = 9101                # where we listen for UA connections
  QueryFile = "/etc/bacula/scripts/query.sql"
  WorkingDirectory = "/var/lib/bacula"
  PidDirectory = "/run/bacula"
  Maximum Concurrent Jobs = 20
  Password = "Wt_QD_C4jko69rnP2VCSNIPH1xGjevHJ6"         # Console password
  Messages = Daemon
  DirAddress = 127.0.0.1
}

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Client = ubuntu-fd
  Messages = Standard
  Pool = File
  SpoolAttributes = yes
  Priority = 10
  Write Bootstrap = "/var/lib/bacula/%c.bsr"
}


# Generic catalog service
Catalog {
  Name = MyCatalog
  dbname = "bacula"; DB Address = "localhost"; dbuser = "bacula"; dbpassword = "db_password"
}

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

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
}

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 = all, !skipped
  operator = root = mount
  console = all, !skipped, !saved
  append = "/var/log/bacula/bacula.log" = all, !skipped
  catalog = all
}


# File Pool definition
Pool {
  Name = File
  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
  Label Format = "Vol-"               # Auto label
}


# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}

#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
  Name = ubuntu-mon
  Password = "YyYsnzC5HGotILRMoNStxhq0k31B0hKg2"
  CommandACL = status, .status
}

Storage {
  Name = ubuntu-dir 
  Address = 127.0.0.1
  Password = "WMYDtJXi2aqlU8ReuoUPUVkg6ny0yqgYF"
  Device = Local-device
  Media Type = File
}

FileSet {
  Name = "Local-file"
  Include {
    Options {
      signature = MD5
    }
    File = /var/www/html
  }
}

Schedule {
  Name = "LocalDaily"
  Run = Full daily at 06:00
}

Job {
  Name = "LocalBackup"
  JobDefs = "DefaultJob"
  Enabled = yes
  Level = Full
  FileSet = "Local-file"
  Schedule = "LocalDaily"
  Storage = ubuntu-dir
  Write Bootstrap = "/var/lib/bacula/LocalhostBackup.bsr"
}

test conf

bacula-dir -tc /etc/bacula/bacula-dir.conf

start and and enable Bacula

systemctl start bacula-dir
systemctl enable bacula-dir

manual run

bconsole
*run
*status director
Scheduled Jobs:
Level          Type     Pri  Scheduled          Job Name           Volume
===================================================================================
Full           Backup    10  23-Jun-21 06:00    LocalBackup        Vol-0001
====

Running Jobs:
Console connected at 23-Jun-21 05:18
No Jobs running.
====

Terminated Jobs:
 JobId  Level      Files    Bytes   Status   Finished        Name 
====================================================================
     1  Full           2         3   OK       23-Jun-21 05:18 LocalBackup

check back up directory

# ls /data/
Vol-0001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment