Skip to main content

파일백업을위한 bareos 소개

Bareos 소개

  1. 2000년 1월에 출시한 Opensource Backup인 Bacula의 Fork버전
  2. Bacula는 AGPL v3 + 독점라이선스 , Bareos는 AGPL v3 로 운영
  3. Bacula는 독점라이선스로 운영하면서 커뮤니티보다는 B2B로 모델을 중점으로 두면서 2011년에 Bareos로 Forking되었음
  4. Linux(Centos/Ubuntu/Suse/Debian), Windows등 다양한 OS 환경에서 설치가능
  5. '19년 6월 기준 최신 릴리즈는 18.2.5 버전이 릴리즈.

Bareos 기본 시스템 구성도

  1. Director : 백업 정책 / 스케쥴 / 클라이언트를 관리하는 모듈
  2. sd(storage-daemon) : 백업데이터를 저장하는 모듈
  3. fd(file-daemon) : 백업할 데이터가 저장된 클라이언트
  4. bconsole : 콘솔용 프로그램 (클라이언트 생성 및 백업 정책 설정은 불가)
  5. webui : 웹기반에서 백업 / 복구 job을 수행할 수 있는 모듈 (클라이언트 생성 및 백업 정책 설정은 불가)

Bareos설치하기

  1. Director 설치하기 (frontend용 Apache, Backend용 RDBMS 설치가 필요, 당 문서에는 포함하지 않음)
    1. Director을 위한 패키지 설치
      $> wget https://download.bareos.org/current/EL_7/bareos.repo /etc/yum.repos.d/bareos.repo
      $> yum install bareos bareos-director bareos-common bareos-database-mysql -y
  2. DB구성 (순서대로 진행)
    $> /usr/lib/bareos/scripts/create_bareos_database mysql
    $> /usr/lib/bareos/scripts/make_bareos_tables mysql
    $> /usr/lib/bareos/scripts/grant_bareos_privileges mysql
  3. 서버 구성을 위한 설정파일 구성1. DB구성 파일 생성

    $> cat /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
    Catalog {
     Name = MyCatalog
     dbdriver = "mysql"
     dbname = "{{ DB이름 }}"
     dbuser = "{{ DB접속계정 }}"
     dbpassword = "{{ DB접속패스워드 }}"
     dbsocket=/tmp/mysql.sock
    }

     
    1. Director → SD구성을 위한 파일 정보 수정
      $> cat /etc/bareos/bareos-dir.d/storage/File.conf
      Storage {
       Name = File
       Address =  {{ SD서버IP }}
       Password = "{{ SD연동용 패스워드 }}" // SD서버용 패스워드 설정과 동일해야 함
       Device = FileStorage1
       Device = FileStorage2
        Maximum Concurrent Jobs = 2
        Media Type = File
      }
    2. 스케쥴 정보
      $> cat /etc/bareos/bareos-dir.d/schedule/{{백업 정책 이름}}.conf
      Schedule {
       Name = "{{ 스케쥴 이름 }}"
       Run = Full  mon at 01:00               #Full 백업 수행 날짜와 시간 수행
       Run = Incremental tue-sun at 01:00     #Incremental 백업 수행 날짜와 시간 수행
      }
    3. 백업 수행을 위한 설정 (기본값은 모듈벼로 분리되어 있으나, 운영상 편리를 위해 통합된 config가 효율적인듯...)
      파일명 : /etc/bareos/bareos-dir.d/job/{{클라이언트 이름}}.conf
    4. 클라이언트 정보
      Client {
       Name = {{ 클라이언트 이름 }}
       Description = "Client resource of the Director itself."
       Address = localhost
       Password = "{{ 클라이언트접속용 패스워드 }}"          # password for FileDaemon
      }
    5. 파일셋 설정
      FileSet {
       Name = "{{ 클라이언트 이름 }}"
        Include {
          Options {
           compression=lz4   #파일 압축방식
           signature=SHA1   #암호화 방식 (sha1 / md5 중 가능)
           Sparse = yes
         }
         File = "/usr/sbin"  #백업 경로
         File = "/etc/bareos/"
         File = "/etc/bareos-webui/"
       }
      }
    6. 백업 Job정보
      $>
      Job {
       Name = "{{ 클라이언트 이름 }}"
       JobDefs = "{{ 클라이언트 이름 }}"
       Client = "{{ 클라이언트 이름 }}"
      }
    7. 백업 정책 정보
      $>
      JobDefs {
       Name = "{{ 클라이언트 이름 }}"
       Type = Backup
       Level = {{ 백업 정책이름 }}
       Client = {{ 클라이언트 이름 }}
       FileSet = {{ 클라이언트 이름 }}
       Schedule = "{{ 스케쥴이름 }}"
       Storage = File
       Messages = Standard
       Pool = {{ 클라이언트 이름 }}
       Priority = 10
        Write Bootstrap = "/var/lib/bareos/%c.bsr"
      }
    8. 백업 Pool 정보
      $>
      Pool {
       Name = {{ 클라이언트 이름 }}
        Pool Type = Backup
       Recycle = yes                                      # 볼륨 재사용 여부
       AutoPrune = yes                                    # 보관기간 만료시 Pool에 write되지 않도록 정책 설정
       Volume Retention = 30 days                         # 볼륨 보관 기간
       Maximum Volume Bytes = 100G                        # 파일당 최대기록 용량
       Maximum Volumes = 100                              # 볼륨당 최대 생성 갯수
       Label Format = "{{ 클라이언트 이름 }}-"            # Pool생성 이름
       Purge Oldest Volume = yes
      }
  4. SD구성1. 패키지 설치

    yum install bareos-storage -y
    1. 서버구성을 위한 설정파일 구성
    2. SD실행을 위한 설정
      $> cat /etc/bareos/bareos-sd.d/storage/bareos-sd.conf
      Storage {
       Name = {{ SD이름 }}
        Maximum Concurrent Jobs = 20
      }
    3. Director와 연동을 위한 설정
      $> cat /etc/bareos/bareos-sd.d/director/bareos-dir.conf
      Director {
       Name = {{ Director 이름 }}
       Password = "{{ SD연동용 패스워드 }}"
      }
    4. 장치 설정 정보
      $> cat /etc/bareos/bareos-sd.d/device/FileStorage.conf
      
      Device {
       Name = FileStorage1
        Media Type = File
        Archive Device = /backup <-- 백업 데이터 저장 경로
       LabelMedia = yes;                   # lets Bareos label unlabeled media
       Random Access = yes; <-- HDD처럼 랜덤액세스가 가능한 매체인 경우 yes로 변경(tape는 no로 설정)
       AutomaticMount = yes;
       RemovableMedia = no;
       AlwaysOpen = yes;
        Maximum Concurrent Jobs = 10
      }
  5. FD설정
    1. 패키지 설치
      $> yum install bareos-filedaemon bareos-fd -y
  6. fd설정을 위한 설정
    11.fd서비스 설정

    $> cat /etc/bareos/bareos-fd.d/client/myself.conf
    Client {
     Name = {{클라이언트 이름 }}
      Maximum Concurrent Jobs = 20
    }

    1. director 연동 설정
      $> cat /etc/bareos/bareos-fd.d/director/bareos-dir.conf
      Director {
       Name = {{ Director 이름 }}
       Password = "{{ Director 접속 패스워드 }}"
      }

백업  작업 수행

  1. 백업 / 복구 작업은 webui / bconsole을 이용해 수행이 가능하나, 운영상 편리를 위해 webui에서 수행
  2. Webui 접근 후 Jobs → Run 메뉴 이동
    1. Job : 백업 작업 선택
    2. Client : 백업 클라이언트이름
    3. Fileset : 백업 대상 
    4. Storage : File (기본값)
    5. Pool : 백업데이터 보관주기 설정
    6. Level : 백업유형 (Full / Incremental 중 선택)
    7. Priority : 백업 작업 우선순위 선택
    8. When : 백업 수행시간 (옵션)
  3. Jobs → Show 메뉴 이동
  4. 백업 결과 확인

복구 작업 수행

  1. Restore 메뉴 이동
    1. Client : 복구수행할 클라이언트
    2. Backup Jobs : 백업 했던 job 
    3. Merge all client fileset : 여러개의 파일셋으로 백업된 경우 하나로 합쳐서 복구 수행 (단일 파일셋으로 구성하는 경우 영향없음)
    4. Merge all related jobs to last full backup of selected backup job : 최근에 수행한 백업데이터로 복구 수행
    5. Restore to client : 복구할 클라이언트 수행
    6. Restore job : 기본값
    7. replace files on client : 복구 대상에에서 파일 저장 정책
      1. always : 복구파일로 덮어씀
      2. never : 기존파일 보관
      3. if file being restored is older than existing file : 백구 파일이 오래된 경우 복구파일로 덮어씀
      4. if file being restored is newer than existing file : 백구 파일이 최신인 경우 복구파일로 덮어씀
    8. Restore location on client : 복구 파일 경로
  2. 복구 작업 수행결과 확인