備份哪些資料?

gitlab 上有哪些重要的資料是應該備份的呢?

  1. gitlab 設定檔
  2. 專案資料

備份 gitlab 設定檔

1
2
# 備份資料會放在 /var/opt/gitlab/backups
sudo sh -c 'umask 0077; tar -cf $(date "+/var/opt/gitlab/backups/gitlabconfig-%s.tar") -C / etc/gitlab'

備份 gitlab 專案

1
2
# 備份資料會放在 /var/opt/gitlab/backups.
/opt/gitlab/bin/gitlab-rake gitlab:backup:create

切換身份並設定排程

讓 linux 可以自動定時執行 script

1
2
3
4
# 切換身份執行
sudo crontab -e -u root
# 設定定時工作
15 04 * * 2-6 umask 0077; tar -cf $(date "+/var/opt/gitlab/backups/gitlabconfig-%s.tar") -C / etc/gitlab

同步資料夾到 NAS 中

1
2
3
4
5
#!/usr/bin/bash
cd /home/git/gitlab
fn=`sudo -u git -H rake RAILS_ENV=production gitlab:backup:create | grep 'Creating backup archive:' | awk '{print $4}'`
scp /home/git/gitlab/tmp/backups/$fn root@x.y.z.a:/root/backups/
echo "Backed up file /home/git/gitlab/tmp/backups/$fn to root@x.y.z.a.."

如何設定 SCP

如何設定 rsync

1
rsync -av /var/gitlabBackup/ username@10.1.1.31::IT\ Resources/gitlabBackup

上面的設定都免了直接設定 NFS 就好了,直接備份到 NFS 上

NFS 設定方式

NFS client

執行 mount

1
sudo mount 10.1.1.31:/volume1/NetBackup /mnt/

發生錯誤

1
2
3
4
5
6
mount: wrong fs type, bad option, bad superblock on 10.1.1.31:/volume1/NetBackup,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so

原來是需要安裝 nfs 的套件

1
sudo apt-get install nfs-common

然後就可以掛載

1
sudo mount 10.1.1.31:/volume1/NetBackup gitlabBackup/

掛載前還需要先建立資料夾

1
mkdir gitlabBackup

結論

綜合以上的文獻資料,具體的作法:

  1. 先將 NAS 資料夾掛接到 Gitlab Server
  2. 透過 crontab 設定工作排程
  3. 完成

留言與分享

ubuntu 安裝 Fish shell

> 詳細教學 install-fish-shell-mac-ubuntu

1
sudo apt-add-repository ppa:fish-shell/release-2

遇到:執行 add-apt-repository 指令之後,出現「Command not found」的訊息
解決方式

1
apt-get install software-properties-common

然後升級 apt-get 然後 install

1
2
sudo apt-get update
sudo apt-get install fish

把 Fish 設定為預設 shell 工具:

1
chsh -s /usr/bin/fish

升級 apt ( Advanced Packaging Tools )

1
apt-get update
1
apt-get upgrade

升級 git

1
2
3
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

安裝 OMF

1
2
curl -L https://get.oh-my.fish > install
fish install --path=~/.local/share/omf --config=~/.config/omf

安裝主題

1
2
3
4
omf install bobthefish
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v1.0.0/FiraCode.zip
sudo unzip FiraCode.zip -d /usr/local/share/fonts/
sudo fc-cache -fv

留言與分享

  • 第 1 頁 共 1 頁
作者的圖片

James Yang

author.bio


author.job