docker gitlab 備份 恢復 版本升級(16.1.1到18.2.0)

docker 啟動

# 在線
docker pull gitlab/gitlab-ce:latest
# 離線
docker save -o gitlab-ce-latest.tar gitlab/gitlab-ce:latest
docker load -i gitlab-ce-latest.tar
docker run --detach \--publish 8021:80 --publish 8023:22 \ --name gitlab_test \--restart always \--volume /data/docker/gitlab_test/config:/etc/gitlab \--volume /data/docker/gitlab_test/logs:/var/log/gitlab \--volume /data/docker/gitlab_test/data:/var/opt/gitlab \gitlab/gitlab-ce:latest

備份

  • 50_backup.sh
  • 0 1 * * 1 nohup sh /data/zhengqi_data/shanghai_backup/50_backup.sh >> /data/zhengqi_data/shanghai_backup/50_backup.out 2>1&
#!/bin/sh
# 獲取當前日期
current_date=$(date +%Y%m%d%H%M%S)
backup_path=/data/zhengqi_data/shanghai_backup
echo "開始執行備份腳本,當前時間$current_date"echo "創建gitlab備份包"
git_path=/data/docker/gitlab
git_new_backup_path=$backup_path/gitlab/$current_date
git_old_backup_path=$(find "$backup_path"/gitlab -type d -mindepth 1 -maxdepth 1 | head -n 1)
echo "舊gitlab備份文件路徑====>$git_old_backup_path"
git_path_backup=$git_path/data/backups/$current_date
sudo  docker exec -t gitlab  gitlab-rake gitlab:backup:create BACKUP=$git_path_backup
echo "創建完成"
echo "轉移至備份文件夾"
mkdir -p  $git_new_backup_path/data
mkdir -p  $git_new_backup_path/configmv "$git_path_backup"_gitlab_backup.tar $git_new_backup_path/data
cp $git_path/config/gitlab.rb  $git_new_backup_path/config
cp $git_path/config/gitlab-secrets.json  $git_new_backup_path/config
echo "轉移完成"
echo "清理本機舊備份內容"
# 檢查文件夾是否存在
if [ -d "$git_old_backup_path" ]; then# 如果存在,刪除文件夾及其內容rm -r "$git_old_backup_path"echo "文件夾刪除成功 $git_old_backup_path"
elseecho "文件夾不存在: $git_old_backup_path"
fi
echo "備份結束"

恢復

# 進入容器
# 停止 GitLab 容器
docker stop gitlab_test # 啟動 GitLab 容器
docker start gitlab_test docker exec -it gitlab_test /bin/bash
chmod 777 /var/opt/gitlab/backups/20250714100001_gitlab_backup.tar
# gitlab-backup restore BACKUP=20250714100001
root@ea0b9740515c:/# gitlab-backup restore BACKUP=20250714100001
2025-07-18 07:00:04 UTC -- Unpacking backup ... 
2025-07-18 07:02:58 UTC -- Unpacking backup ... done
2025-07-18 07:02:58 UTC -- Restoring database ... 
2025-07-18 07:02:58 UTC -- Be sure to stop Puma, Sidekiq, and any other process that
connects to the database before proceeding. For Omnibus
installs, see the following link for more information:
https://docs.gitlab.com/ee/raketasks/backup_restore.html#restore-for-omnibus-gitlab-installationsBefore restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
custom tables in the GitLab database these tables and all data will be
removed.Do you want to continue (yes/no)? yes2025-07-18 07:16:14 UTC -- Restoring repositories ... done
2025-07-18 07:16:14 UTC -- Restoring uploads ... 
2025-07-18 07:16:14 UTC -- Restoring uploads ... done
2025-07-18 07:16:14 UTC -- Restoring builds ... 
2025-07-18 07:16:14 UTC -- Restoring builds ... done
2025-07-18 07:16:14 UTC -- Restoring artifacts ... 
2025-07-18 07:16:14 UTC -- Restoring artifacts ... done
2025-07-18 07:16:14 UTC -- Restoring pages ... 
2025-07-18 07:16:14 UTC -- Restoring pages ... done
2025-07-18 07:16:14 UTC -- Restoring lfs objects ... 
2025-07-18 07:16:14 UTC -- Restoring lfs objects ... done
2025-07-18 07:16:14 UTC -- Restoring terraform states ... 
2025-07-18 07:16:14 UTC -- Restoring terraform states ... done
2025-07-18 07:16:14 UTC -- Restoring packages ... 
2025-07-18 07:16:14 UTC -- Restoring packages ... done
2025-07-18 07:16:14 UTC -- Restoring ci secure files ... 
2025-07-18 07:16:14 UTC -- Restoring ci secure files ... done
This task will now rebuild the authorized_keys file.
You will lose any data stored in the authorized_keys file.
Do you want to continue (yes/no)? yes2025-07-18 07:39:40 UTC -- Deleting tar staging files ... 
2025-07-18 07:39:40 UTC -- Cleaning up /var/opt/gitlab/backups/backup_information.yml
2025-07-18 07:39:40 UTC -- Cleaning up /var/opt/gitlab/backups/db
2025-07-18 07:39:40 UTC -- Cleaning up /var/opt/gitlab/backups/repositories
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/uploads.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/builds.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/artifacts.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/pages.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/lfs.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/terraform_state.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/packages.tar.gz
2025-07-18 07:39:44 UTC -- Cleaning up /var/opt/gitlab/backups/ci_secure_files.tar.gz
2025-07-18 07:39:44 UTC -- Deleting tar staging files ... done
2025-07-18 07:39:44 UTC -- Deleting backups/tmp ... 
2025-07-18 07:39:44 UTC -- Deleting backups/tmp ... done
2025-07-18 07:39:44 UTC -- Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
and are not included in this backup. You will need to restore these files manually.
2025-07-18 07:39:44 UTC -- Restore task is done.
2025-07-18 07:39:44 UTC -- Deleting backup and restore PID file ... done# 復制配置文件到容器掛載目錄(宿主機操作)
cp /path/to/backup/gitlab.rb /srv/gitlab/config/
cp /path/to/backup/gitlab-secrets.json /srv/gitlab/config/# 重新配置 GitLab(容器內執行)
gitlab-ctl reconfigure# 重啟 GitLab 服務(容器內執行)
gitlab-ctl restart
  • 權限異常
root@2504f64e41e6:/var/opt/gitlab/backups# gitlab-backup restore BACKUP=/var/opt/gitlab/backups/20250714100001
2025-07-18 02:52:30 UTC -- Unpacking backup ... 
tar: 20250714100001_gitlab_backup.tar: Cannot open: Permission denied
tar: Error is not recoverable: exiting now
2025-07-18 02:52:30 UTC -- Unpacking backup failed
2025-07-18 02:52:30 UTC -- Deleting backup and restore PID file at [/opt/gitlab/embedded/service/gitlab-rails/tmp/backup_restore.pid] ... done
root@2504f64e41e6:/var/opt/gitlab/backups# ll
total 17082276
drwx------  2 git  root        4096 Jul 18 02:26 ./
drwxr-xr-x 20 root root        4096 Jul 18 02:36 ../
-rw-------  1 root root 17492234240 Jul 18 02:29 20250714100001_gitlab_backup.tar

gitlab升級 16.1.1到18.2.0

官方升級路徑

  • 2 3 4 5 步驟重復執行
# 1. 停止當前容器
docker stop gitlab
docker rm gitlab# 2. 拉取 版本鏡像
docker pull gitlab/gitlab-ce:16.3.9-ce.0
docker pull gitlab/gitlab-ce:16.7.10-ce.0
docker pull gitlab/gitlab-ce:16.11.10-ce.0
docker pull gitlab/gitlab-ce:17.1.8-ce.0
docker pull gitlab/gitlab-ce:17.3.7-ce.0
docker pull gitlab/gitlab-ce:17.5.5-ce.0
docker pull gitlab/gitlab-ce:17.8.7-ce.0
docker pull gitlab/gitlab-ce:17.11.6-ce.0
docker pull gitlab/gitlab-ce:18.2.0-ce.0# 3. 使用相同數據卷啟動新容器
docker run -d \--hostname your.gitlab.com \--publish 443:443 --publish 80:80 --publish 22:22 \--name gitlab \--restart always \--volume /srv/gitlab/config:/etc/gitlab \--volume /srv/gitlab/logs:/var/log/gitlab \--volume /srv/gitlab/data:/var/opt/gitlab \gitlab/gitlab-ee:16.10.7-ee.0# 4. 等待啟動完成后,執行重新配置(觸發自動升級)
docker exec -it gitlab gitlab-ctl reconfigure
docker exec -it gitlab gitlab-ctl restart# 5. 驗證升級結果
docker exec -it gitlab gitlab-rake gitlab:check SANITIZE=true

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/89619.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/89619.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/89619.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

web3 區塊鏈技術與用

#53 敲點算法題 瑞吉外賣day4 調整心態 睡眠 及精神 web3 以下是應北京大學肖臻老師《區塊鏈技術與用》公開課的完整教學大綱,綜合課程內容、技術模塊及前沿擴展,分為核心章節與專題拓展兩部分,引用自公開課資料及學員筆記。 &#x1f4…

Redis1:高并發與微服務中的鍵值存儲利器

redis中存儲的數據格式為鍵值對(Key,Value)在高并發的項目和微服務的項目會頻繁的用到redisNoSQL型數據庫1.初始Redis1.1認識NoSQLSQL:structure query language關系型數據庫結構化:有固定格式要求(表關系,…

/字符串/

字符串 個人模板 5. 最長回文子串 93. 復原 IP 地址 43. 字符串相乘 227. 基本計算器 II

我的開發日志:隨機數小程序

文章目錄前言UI設計代碼前言 為什么我要設計這個程序呢?因為我要用,懶得在網上下載了,于是干脆寫了一個。 UI設計 UI是我凹出來的,你們要使用,直接新建一個UI.ui文件,然后把下面的東西輸進去就可以了。 …

《Oracle SQL:使用 RTRIM 和 TO_CHAR 函數格式化數字并移除多余小數點》

select RTRIM(to_char(1222.11123344,fm9999990.9999),.) from dual 這條 SQL 語句主要用于對數字進行格式化處理,并移除格式化結果右側多余的小數點。下面將詳細拆解該語句的執行過程和各部分作用。語句詳細拆解1. to_char(1222.11123344,fm9999990.9999)函數功能&…

「Java案例」方法重裝求不同類型數的立方

利用方法重裝實現不同類型數值的立方計算 立方計算方法的重載實現 編寫一個程序,要求編寫重載方法xxx cube(xxx value)實現對不同類型數值計算立方。 # 源文件保存為“CubeCalculator.java” public class CubeCalculator {public static void main(String[] args) {// 測試…

API 接口開發與接入實踐:自動化采集淘寶商品數據

在電商數據分析、價格監控等場景中,自動化采集淘寶商品數據具有重要價值。本文將詳細介紹如何通過 API 接口開發實現淘寶商品數據的自動化采集,包含完整的技術方案和代碼實現。 一、淘寶 API 接入基礎 1. 接入流程概述 注冊淘寶賬號獲取 ApiKey 和 Ap…

python-pptx 的layout 布局

一、布局基礎概念 在 PowerPoint 中,布局(Layout) 決定了幻燈片的占位符(如標題、內容、圖片等)的排列方式。python-pptx 提供了對布局的編程控制。二、默認布局類型及索引 通過 prs.slide_layouts[index] 訪問&#x…

服務器mysql數據的簡單備份腳本

服務器mysql數據的簡單備份腳本 一個小型項目mysql數據庫數據的定時備份 通過crontab定時執行腳本: 0 1 * * * /home/yuyu/mysqlbak.sh備份文件加入時間戳,防止覆蓋支持刪除超過x天的備份數據文件,防止備份數據文件太多 #!/bin/bash# 配置變量 DB_HOST"127.0.…

數據分析:從數據到決策的核心邏輯與實踐指南

在數據驅動決策的時代,“數據分析” 早已不是專業分析師的專屬技能,而是每個職場人都需要掌握的基礎能力。但很多人在面對數據時,常會陷入 “羅列數據卻無結論”“指標好看卻解決不了問題” 的困境。本文將基于數據分析的核心定義、關鍵維度和…

元宇宙與Web3.0:技術特征、關系及挑戰

一、元宇宙的技術特征(2025年)1. 空間構建技術3D建模與渲染:實時渲染技術(如Unity HDRP)實現路徑追蹤光追,AI生成模型(NVIDIA Get3D)3秒生成3D場景。數字孿生技術:城市級…

關于一個引力問題的回答,兼談AI助學作用

關于一個引力問題的回答,兼談AI助學作用今日,一個小朋友問我,他從一本物理科普讀物上看到這樣依據話:地球對人造地球衛星的引力大于太陽對人造地球衛星的引力,但太陽對月亮的引力大于地球對月亮的引力。因書上沒有解釋…

Java使用FastExcel實現模板寫入導出(多級表頭)

依賴配置 (Maven pom.xml)<dependencies><!-- FastExcel 核心庫 --><dependency><groupId>cn.idev.excel</groupId><artifactId>fastexcel</artifactId><version>1.0.0</version></dependency><!-- Apache POI…

postman接口測試,1個參數有好幾個值的時候如何測試比較簡單快速?

3天精通Postman接口測試手動到自動&#xff0c;全套項目實戰教程&#xff01;&#xff01;當你在 Postman 中測試接口時&#xff0c;如果一個參數有多個需要測試的值&#xff0c;有幾種高效的方法可以實現&#xff1a; 1. 使用 CSV 或 JSON 數據文件進行數據驅動測試 這是最推…

imx6ull UI開發

imx6ull UI開發簡介在imx6ull上開發UI 應用硬件層面內核驅動顯示設備文件描述符設備樹軟件LVGL用戶空間內核QT在imx6ull上開發UI 應用 在 Linux 系統中&#xff0c;應用程序需要通過操作 RGB LCD 的顯存來實現在屏幕上顯示字符、圖像等信息。由于 Linux 采用嚴格的內存管理機制…

虛擬化測試工具Parasoft Virtualize如何為汽車企業提供仿真測試?

在汽車電子研發中&#xff0c;傳統路測曾是驗證ECU&#xff08;電子控制單元&#xff09;、車載通信、OTA升級等功能的可靠手段。然而&#xff0c;隨著智能駕駛和軟件定義汽車&#xff08;SDV&#xff09;的發展&#xff0c;這種依賴物理車輛的測試方式面臨顯著挑戰&#xff1a…

QT之openGL使用(一)

OpenGL簡介 官網&#xff1a;OpenGL - The Industry Standard for High Performance Graphics 中文官網&#xff1a;主頁 - LearnOpenGL CN OpenGL&#xff08;Open Graphics Library&#xff09;是一種跨語言、跨平臺的圖形編程接口&#xff0c;主要用于渲染二維和三維矢量…

基于生成對抗網絡增強主動學習的超高溫陶瓷硬度優化

復現論文:基于生成對抗網絡增強主動學習的超高溫陶瓷硬度優化 我將使用Python復現這篇關于使用生成對抗網絡(GAN)增強主動學習來優化超高溫陶瓷(UHTC)硬度的研究論文。以下是完整的實現代碼和解釋。 1. 環境準備和數據加載 首先,我們需要準備必要的Python庫并加載數據。 …

hadoop(服務器偽分布式搭建)

1. 報錯 Windows 上寫的腳本 拷貝到 Linux&#xff08;比如 CentOS&#xff09;系統時會出現。 bash: ./set_java_home.sh: /bin/bash^M: bad interpreter: No such file or directory 報錯原因 ^M 是 Windows 的換行符&#xff08;\r\n&#xff09; Linux 使用的是 Unix 格式的…

超詳細 anji-captcha滑塊驗證springboot+uniapp微信小程序前后端組合

目錄 1&#xff1a;pom文件引入jar包 2&#xff1a;配置文件 3&#xff1a;踩坑-1 4&#xff1a;踩坑-2 5&#xff1a;后端二次驗證 6&#xff1a;自定義背景圖 給用戶做的一個小程序&#xff0c;被某局安全驗證后&#xff0c;說登錄太簡單&#xff0c;沒有驗證碼等行為認…