LoginSignup
0
0

More than 3 years have passed since last update.

borg で gitbucket のデータの差分バックアップをするまでの道のり

Last updated at Posted at 2019-03-29

2019/03/28 現在

背景

gitbucket が壊れて、復帰するのに難儀したので、差し戻しが出来る様に、
バックアップしたい。

CentOS7

tomcat/gitbucket を利用。

  • borg1.1 系
  • /usr/share/tomcat/.gitbucket を /root/backups に差分バックアップする。
  • クローズドなので、暗号化なんかは端折る。
  • ログとかも無視。

インストール

$ wget https://github.com/borgbackup/borg/releases/download/1.1.9/borg-linux64
$ sudo chown root:root borg-linux64
$ sudo chmod 755 borg-linux64
$ sudo mv borg-linux64 /usr/local/bin/borg

最初のバックアップ

以下、root で作業

# pwd
/root
# mkdir -p bakups
# borg init -e none /root/backups
# brog create /root/backups::gitbucket-2019032819 /usr/share/tomcat/.gitbucket

init で保存場所の宣言、create で、gitbucket-2019032819 のレポジトリを作成

定期実行

残すのは、直近7日、2週前までの二つ、1月前までの一つ

# cat /root/scripts/borg.sh
#!/bin/bash

borg_exe=/usr/local/bin/borg
date=$(date "+%Y%m%d%H" )
src=/usr/share/tomcat/.gitbucket
dest=/root/backups

$borg_exe create ${dest}::gitbucket-${date} ${src}                        > /dev/null 2>&1
$borg_exe prune --keep-within=7d --keep-weekly=2 --keep-monthly=-1 ${dest} > /dev/null 2>&1

実行してみて、確認する1

# bash /root/scripts/borg.sh

で、夜中の23時に差分バックアップするには、root の crontab に

0 23 * * * /bin/bash /root/scripts/borg.sh

と書けばいい。

メモ

復帰させるときは、

// tomcat の停止
# systemctl stop  tomcat
// 壊れた gitbucket のデータを削除
# rm -rf  /usr/share/tomcat/.gitbucket
// 復帰
# borg extract /root/backups::gitbucket-YYYYMMDDhh /usr/share/tomcat/.gitbucket
// tomcat のスタート
# systemctl start  tomcat

あたりでいいのかな?


  1. もちろん、既存のbackupと被らない様に、$dateは適当に編集。 

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0