Borgmaticのインストールと設定

0 株式
0
0
0
0

導入

このチュートリアルでは、Borgmaticの概要と、サーバーのシステム全体をストレージボックスにバックアップする方法について説明します。Borgmaticは、BorgBackupの使用を簡素化し、いくつかの機能を追加して拡張するシンプルなツールです。.

前提条件
  • バックアップする Linux サーバー。.
  • 十分な空き容量と SSH キーが設定されたストレージ ボックス。.

ステップ1 – Borgmaticのインストールと設定

このステップでは、Borgmatic をインストールして構成する方法について説明します。.

ステップ1.1 BorgBackupとBorgmaticをインストールする

Borgmatic には BorgBackup が自動的に含まれないので、両方のパッケージを手動でインストールする必要があります。

apt install borgbackup borgmatic
ステップ1.2 – ボーグマティック構成

設定例はgenerateで作成できる。

generate-borgmatic-config

これは、例の値を含む構成です /etc/borgmatic/conf.yml 作成します。.

このチュートリアルでは、次の設定を使用できます。

location:
    # Here you can specify a list of Storage Boxes as backup target.
    repositories:
        - [email protected]-storagebox.de:backups

    # A list of all directoy which should be included within the backup.
    # As we want to create a full system backup "/" is sufficient.
    source_directories:
        - /

    # Exclude the default mount directory and any directories which are created at runtime.
    exclude_patterns:
        - /dev
        - /proc
        - /sys
        - /var/run
        - /run
        - /mnt
        - /tmp

storage:
    # Here you can specify the password which is used to encrypt your backups. This is _not_ your Storage Box password.
    # Do not lose this. Otherwise you are not able to restore your backup later.
    encryption_passphrase: "<SUPER SECRET PASSWORD>"

    # As BorgBackup is running on port 23 on the Storage Boxes, we have to overwrite the default ssh command in order to specify a port.
    ssh_command: "ssh -p 23"

# Here you can specify how many backups should be kept at minumim for the specified time frame.
retention:
    keep_daily: 7
    keep_weekly: 4
    keep_monthly: 6
    keep_yearly: 1
 
ステップ1.3 – 最初のバックアップの設定と作成

最初のバックアップを作成する前に、まずバックアップ リポジトリを初期化する必要があります。.

borgmatic init --encryption repokey --verbosity 1

準備が正常に完了したら、最初のバックアップを作成できます。.

borgmatic --verbosity 1

サーバーのサイズによっては、最初のバックアップに時間がかかる場合があります。次回以降のバックアップは増分バックアップのみなので、より高速になります。.

ステップ2 – 自動化

から systemctl ステータス borgmatic.timer borgmatic.service サービスとタイマーがすでに存在するかどうかを確認するために使用します。.

  • 次のようなエラーが発生した場合 ユニット borgmatic.XXX が見つかりませんでした 受け取っていない場合は、以下の手順に従ってください。.
  • ユニットが見つかり、そのステータスを表示できる場合は、この手順をスキップできます。.

これを自動化するためにシステムユニットとタイマーを使用します。バックアップを開始する部分は /etc/systemd/system/borgmatic.service コピー。.

[Unit]
Description=Borgmatic system backup
Requires=network.target
After=network.target

[Service]
Type=oneshot
Nice=10
IOSchedulingClass=best-effort
IOSchedulingPriority=6
ProtectSystem=full
ExecStart=/usr/bin/borgmatic --verbosity -1 --syslog-verbosity 1

次のセクションは、定期的にバックアップを開始する役割を担っています。これは、 /etc/systemd/system/borgmatic.timer コピー

[Unit]
Description=Daily backup timer

[Timer]
OnCalendar=*-*-* 16:30:00
Persistent=true

[Install]
WantedBy=timers.target

ここでタイマーをアクティブにするだけです。

systemctl enable --now borgmatic.timer

タイマーは毎日午後 4:30 にバックアップを開始します。.

結果

Borgmaticは、システムのバックアップを可能にするシンプルながらも強力なツールです。データ損失を防ぐために、自動バックアップを設定しました。.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

あなたも気に入るかもしれない