顯示具有 Git 標籤的文章。 顯示所有文章
顯示具有 Git 標籤的文章。 顯示所有文章

2019年10月1日 星期二

Gitlab 備份筆記


主要指令:
git-server@ubuntu:/opt/gitlab/bin$ gitlab-rake gitlab:backup:create
/usr/bin/gitlab-rake error: could not load /opt/gitlab/etc/gitlab-rails/gitlab-r                                                                                               ails-rc
Either you are not allowed to read the file, or it does not exist yet.
You can generate it with:   sudo gitlab-ctl reconfigure
git-server@ubuntu:/opt/gitlab/bin$ sudo gitlab-rake gitlab:backup:create
2019-10-07 15:16:40 +0800 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2019-10-07 15:16:41 +0800 -- done
2019-10-07 15:16:41 +0800 -- Dumping repositories ...
 * yuching/ofco_ching (@hashed/4e/07/4e07408562bedb8b60ce05c1decfe3ad16b72230967                                                                                               de01f640b7e4729b49fce) ... [SKIPPED]
[SKIPPED] Wiki
 * yenpc/my_first_test (@hashed/79/02/7902699be42c8a8e46fbbb4501726517e86b22c56a                                                                                               189f7625a6da49081b2451) ... [DONE]
[SKIPPED] Wiki
 * sapido-iot/egssys (@hashed/3f/db/3fdba35f04dc8c462986c992bcf875546257113072a9                                                                                               09c162f7e470e581e278) ... [DONE]
[SKIPPED] Wiki

:::

2019-10-07 15:22:23 +0800 -- done
2019-10-07 15:22:23 +0800 -- Dumping lfs objects ...
2019-10-07 15:22:23 +0800 -- done
2019-10-07 15:22:23 +0800 -- Dumping container registry images ...
2019-10-07 15:22:23 +0800 -- [DISABLED]
Creating backup archive: 1570432943_2019_10_07_12.0.3_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.
有些需要手動備份的檔案

root@ubuntu:/var/opt/gitlab/backups# pwd
/var/opt/gitlab/backups

root@ubuntu:/var/opt/gitlab/backups# ls -al
total 20964304
drwx------  2 git  root        4096 Oct  7 15:24 .
drwxr-xr-x 21 root root        4096 Jul 31 15:14 ..
-rw-------  1 git  git  21467432960 Oct  7 15:24 1570432943_2019_10_07_12.0.3_gitlab_backup.tar
備份檔在此

\\192.168.88.16\GitlabBackup
User:backup
Password:R@Sns6
/mnt/nas/GitlabBackupFolder

Edit /etc/gitlab/gitlab.rb
1.gitlab_rails[`backup_path`] 的內容修改成 /mnt/nas/GitlabBackupFolder

/mnt/nas/GitlabBackupFolder/gitlab_backup

2. 仔細看裡面的設定,還可以設定備份的區間,太舊的會自動幫忙刪除。

執行以下指令,讓修改生效
gitlab-ctl reconfigure
gitlab-ctl restart

=======================================================
將NAS的CIFS sharing folder mount 到ubuntu
MOUNT_POINT=/mnt/nas/GitlabBackupFolder
SHARE_FOLDER=//192.168.88.16/GitlabBackup
DOMAIN=NASsrv01
USERNAME=backup
PASSWORD=****

mount -t cifs $SHARE_FOLDER $MOUNT_POINT -o username="$USERNAME",password="$PASSWORD",domain="$DOMAIN",iocharset=utf8,file_mode=0777,dir_mode=0777,vers=2.0

mount -t cifs //192.168.88.16/GitlabBackup /mnt/nas/GitlabBackupFolder -o username="backup",password="******",domain="NASsrv01",iocharset=utf8,file_mode=0777,dir_mode=0777,vers=2.0

mount -t cifs \\192.168.88.16\GitlabBackup /mnt/nas/GitlabBackupFolder -o username=backup,password="******",domain=NASsrv01,iocharset=utf8,file_mode=0777,dir_mode=0777,guest

// 這裡你也可以不用 guest, 可以使用 gid=xxxx 或 uid=xxxx 來指定給某個群組或個人, guest 只是比較偷懶的作法
// 如果遇到失敗可以檢查一下是否有套件沒裝到,再使用 apt-get install 安裝
// apt-get install nfs-common
// apt-get install cifs-utils

mount.cifs \\192.168.88.16\GitlabBackup GitlabBackupFolder -o username=backup

sudo mount -t cifs //192.168.88.16/GitlabBackup /mnt/nas/GitlabBackupFolder

git-server@ubuntu:/mnt/nas$ sudo mount -t cifs $SHARE_FOLDER $MOUNT_POINT -o username="$USERNAME",password="$PASSWORD",domain="$DOMAIN",iocharset=utf8,file_mode=0777,dir_mode=0777,guest,vers=2.0
git-server@ubuntu:/mnt/nas$ ls
GitlabBackupFolder
git-server@ubuntu:/mnt/nas$ cd GitlabBackupFolder/
git-server@ubuntu:/mnt/nas/GitlabBackupFolder$ ls
'#recycle'   test.txt
git-server@ubuntu:/mnt/nas/GitlabBackupFolder$

https://www.rootop.org/pages/4165.html
ubuntu挂载共享mount error(95): Operation not supported


 gitlab_rails['manage_backup_path'] = true
 gitlab_rails['backup_path'] = "/mnt/nas/GitlabBackupFolder"




Ran chmod 00700  returned 1
Ran chmod 00700  returned 1
chmod 00700 /mnt/nas/GitlabBackupFolder


STDERR: chmod: changing permissions of '': Operation not permitted
=======================================================

Cron Job 排程
sudo crontab -e
## Gitlab Backup
# Launch Gitlab backup service
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
# Copy Gitlab backup file to remote server
0 3 * * * find /var/opt/gitlab/backups/ -name "*gitlab_backup.tar" -mtime -1 -exec /bin/cp -a {} /mnt/nas/GitlabBackupFolder \;
# Retain backup data on local folder in 3 days
0 4 * * * find /var/opt/gitlab/backups/ -name "*gitlab_backup.tar" -mtime +1 -exec rm -rf {} \;
# Retain backup data on local folder in 7 days
0 5 * * * find /mnt/nas/GitlabBackupFolder/ -name "*gitlab_backup.tar" -mtime +7 -exec rm -rf {} \;
成功
=======================================================
find /var/opt/gitlab/backups/ -name "*gitlab_backup.tar" -mtime +1
find /mnt/nas/GitlabBackupFolder/ -name "*gitlab_backup.tar" -mtime +7 -exec rm -rf {} \;


要還原時主要步驟:
先安裝與之前備份時相同版本的 Gitlab
停止 gitlab 的服務
將要還原的備份檔放到 /var/opt/gitlab/backups/ 位置
下指令指定要還原的 TIME_STAMP 備份檔
啟動 gitlab, Create satellites, Check gitlab ... 完成

https://poychang.github.io/gitlab-backup/
Gitlab 備份筆記

http://mycodetub.logdown.com/posts/260395-gitlab-backup-restore-settings-notes
Gitlab 備份/還原設定筆記

Gitlab備份與恢復、遷移與升級
https://www.itread01.com/content/1527863887.html


mkdir -p /mnt/nas/GitlabBackupFolder2
mount -t nfs 192.168.88.16:/volume1/GitlabBackup2 /mnt/nas/GitlabBackupFolder2
mount:  can't find in /etc/fstab.

2019年3月13日 星期三

git commands

git commands

clone
branch
checkout branch##git to switch branch
add .
commit -m "####"
push

git push --set-upstream origin max
remote: Repository not found.
fatal: repository 'https://adc.github.trendmicro.com/BA-PLS/cd-gcs.git/' not found ??

$ git push
fatal: The current branch kk has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin kk


ext_maxm@tw-maxmu MINGW64 ~/maxTestRepo (kk)
$ git push --set-upstream origin kk

Total 0 (delta 0), reused 0 (delta 0)
To https://adc.github.trendmicro.com/ext-maxm/maxTestRepo.git
 * [new branch]      kk -> kk
Branch 'kk' set up to track remote branch 'kk' from 'origin'.

ext_maxm@tw-maxmu MINGW64 ~/maxTestRepo (kk)
$

ext_maxm@tw-maxmu MINGW64 ~/maxTestRepo (kk)

==========================================
0308 all process

>git pull
>git branch ReadFromLast2FALSE
>git checkout ReadFromLast2FALSE
>git branch
* ReadFromLast2FALSE
  add_lmp
  master
  max0305
  max0307
  max2


>git add .
Edit code
>git add .

>git commit -m "ReadFromLast TRUE2FALSE"
[ReadFromLast2FALSE 1fb8ed5] ReadFromLast TRUE2FALSE
 Committer: Max Mu (EXT-TW) <max_mu@trendmicro.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 4 files changed, 32 insertions(+), 20 deletions(-)

>git tag "1.2.12"
>git push
(or >git push --set-upstream origin add_lmp)
>git push --tags




Docker Command

#1 pull images $docker pull chusiang/takaojs1607 #2 list images $docker images #3.1 run docker $docker run -it ### bash #3.2 run do...