7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jenkinsのバックアップをThinBackupプラグインで実装

Last updated at Posted at 2016-12-22

2/23追記:
 移行するにはworkspace以外全部うつすといいっぽい。
 (部分バックアップしたらシステム設定が移らなかったりしました)
 参考:http://snickerjp.blogspot.jp/2013/10/migrate-JenkinsCI.html

tarアーカイブしてS3転送のスクリプト書いてもよかったけど、
ThinBackupプラグインをつかったほうが楽な感じだったので。

ThinBackupプラグインの設定をする

Jenkinsの管理>ThinBackup>Settings

・Backup directory
/var/lib/jenkins/backup

※ディレクトリは読み書きできる場所に自分で作っておく

・Backup schedule for full backups
H 12 * * 1-5

・Max number of backup sets
2

・Files excluded from backup (regular expression)

(builds|disabled)/.*$

・Wait until Jenkins/Hudson is idle to perform a backup
初期値でチェック有
Force Jenkins to quiet mode after specified minutes 120

・とっておきたいBackup~にチェックを入れる
Backup next build number file
Backup plugins archives
Backup additional files
Files included in backup (regular expression)
^(\.ssh|config|id_rsa.*|authorized_keys|\.gitconfig)|^(secrets|[a-zA-Z.-_]*)

Move old backups to ZIP files

以上でSAVE。

動作確認

Backup Nowを押す
すると、
/var/lib/jenkins/backup/に日時フォルダができる。
目的の内容がバックアップされたか等を確認
(特に正規表現まわりのinclude/excludeな指定が間違ってないか)

ローカルバックアップだと心もとないのでS3に送るジョブを作る

・upload-jenkins-backup-to-S3
 定期的に実行 H 14 * * *
 Mask passwords (and enable global passwords)
  AWS_ACCESS_KEY_IDとAWS_SECRET_ACCESS_KEYなどを変数化

 シェルの実行

cd /var/lib/jenkins/backup
aws s3 sync ./ s3://${S3BUCKET}/${URI} --delete --acl private

ビルド実行して問題なくupされてたので完了。

参考:
http://sue445.hatenablog.com/entry/2013/12/08/005317
http://yoshio.velvet.jp/blog/archives/4149
https://wiki.jenkins-ci.org/display/JENKINS/thinBackup
http://qiita.com/tq_jappy/items/3654059d09a4896ae598
https://jenkins.io/blog/2010/02/10/keeping-your-configuration-and-data-in-subversion/

7
5
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
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?