<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Moving repositories managed by GitLab > 原文:[https://docs.gitlab.com/ee/administration/operations/moving_repositories.html](https://docs.gitlab.com/ee/administration/operations/moving_repositories.html) * [Target directory is empty: use a tar pipe](#target-directory-is-empty-use-a-tar-pipe) * [Tar pipe to another server](#tar-pipe-to-another-server) * [The target directory contains an outdated copy of the repositories: use rsync](#the-target-directory-contains-an-outdated-copy-of-the-repositories-use-rsync) * [Single rsync to another server](#single-rsync-to-another-server) * [Thousands of Git repositories: use one rsync per repository](#thousands-of-git-repositories-use-one-rsync-per-repository) * [Parallel rsync for all repositories known to GitLab](#parallel-rsync-for-all-repositories-known-to-gitlab) * [Parallel rsync only for repositories with recent activity](#parallel-rsync-only-for-repositories-with-recent-activity) # Moving repositories managed by GitLab[](#moving-repositories-managed-by-gitlab "Permalink") 有時,您需要將 GitLab 管理的所有存儲庫移至另一個文件系統或另一個服務器. 在本文檔中,我們將介紹將所有存儲庫從`/var/opt/gitlab/git-data/repositories` `/mnt/gitlab/repositories`到`/mnt/gitlab/repositories` . 我們將研究三種情況:目標目錄為空,目標目錄包含版本庫的過時副本,以及如何處理數千個版本庫. **我們列出的每種方法都可以/將覆蓋目標目錄`/mnt/gitlab/repositories` . 不要混淆源和目標.** ## Target directory is empty: use a tar pipe[](#target-directory-is-empty-use-a-tar-pipe "Permalink") 如果目標目錄`/mnt/gitlab/repositories`為空,則最簡單的操作是使用 tar 管道. 此方法的開銷很低,并且 tar 幾乎總是已安裝在系統上. 但是,無法恢復中斷的 tar 管道:如果發生這種情況,則必須再次復制所有數據. ``` sudo -u git sh -c 'tar -C /var/opt/gitlab/git-data/repositories -cf - -- . |\ tar -C /mnt/gitlab/repositories -xf -' ``` 如果要查看進度,請用`-xvf`替換`-xf` . ### Tar pipe to another server[](#tar-pipe-to-another-server "Permalink") You can also use a tar pipe to copy data to another server. If your `git` user has SSH access to the new server as `git@newserver`, you can pipe the data through SSH. ``` sudo -u git sh -c 'tar -C /var/opt/gitlab/git-data/repositories -cf - -- . |\ ssh git@newserver tar -C /mnt/gitlab/repositories -xf -' ``` 如果您想在數據通過網絡之前進行壓縮(這將花費您的 CPU 周期),則可以將`ssh`替換為`ssh -C` . ## The target directory contains an outdated copy of the repositories: use rsync[](#the-target-directory-contains-an-outdated-copy-of-the-repositories-use-rsync "Permalink") 如果目標目錄已經包含部分/過時的存儲庫副本,那么再次用 tar 復制所有數據可能會很浪費. 在這種情況下,最好使用 rsync. 該實用程序已經安裝在系統上,也可以通過 apt,yum 等輕松安裝. ``` sudo -u git sh -c 'rsync -a --delete /var/opt/gitlab/git-data/repositories/. \ /mnt/gitlab/repositories' ``` `/.` 在上面的命令中非常重要,沒有它,您很容易在目標目錄中獲得錯誤的目錄結構. 如果要查看進度,請用`-av`替換`-a` . ### Single rsync to another server[](#single-rsync-to-another-server "Permalink") 如果源系統上的`git`用戶對目標服務器具有 SSH 訪問權限,則可以使用 rsync 通過網絡發送存儲庫. ``` sudo -u git sh -c 'rsync -a --delete /var/opt/gitlab/git-data/repositories/. \ git@newserver:/mnt/gitlab/repositories' ``` ## Thousands of Git repositories: use one rsync per repository[](#thousands-of-git-repositories-use-one-rsync-per-repository "Permalink") 每次啟動 rsync 作業時,它都必須檢查源目錄中的所有文件,目標目錄中的所有文件,然后確定要復制或不復制哪些文件. 如果源目錄或目標目錄中包含許多內容,則 rsync 的啟動階段可能會成為您的 GitLab 服務器的負擔. 在這種情況下,可以通過將 rsync 的工作分成較小的部分來使 rsync 的工作變得更輕松,并一次同步一個存儲庫. 除了 rsync 之外,我們還將使用[GNU Parallel](http://www.gnu.org/software/parallel/) . 該實用程序未包含在 GitLab 中,因此您需要使用 apt 或 yum 自己安裝. 還要注意,我們在下面使用的 GitLab 腳本是在 GitLab 8.1 中添加的. **此過程不會清理源位置不再存在的目標位置的存儲庫.** 如果您開始在`/mnt/gitlab/repositories`使用 GitLab 實例,則需要在切換到新的存儲庫存儲目錄后運行`gitlab-rake gitlab:cleanup:repos` . ### Parallel rsync for all repositories known to GitLab[](#parallel-rsync-for-all-repositories-known-to-gitlab "Permalink") 這將一次將存儲庫與 10 個 rsync 進程同步. 我們會跟蹤進度,以便在必要時可以重新開始傳輸. 首先,我們創建一個新目錄,由`git`擁有,以保存傳輸日志. 在開始傳輸過程之前,我們假定目錄為空,并且我們是唯一在其中寫入文件的目錄. ``` # Omnibus sudo mkdir /var/opt/gitlab/transfer-logs sudo chown git:git /var/opt/gitlab/transfer-logs # Source sudo -u git -H mkdir /home/git/transfer-logs ``` 我們使用要復制的目錄列表為該過程添加種子. ``` # Omnibus sudo -u git sh -c 'gitlab-rake gitlab:list_repos > /var/opt/gitlab/transfer-logs/all-repos-$(date +%s).txt' # Source cd /home/git/gitlab sudo -u git -H sh -c 'bundle exec rake gitlab:list_repos > /home/git/transfer-logs/all-repos-$(date +%s).txt' ``` 現在我們可以開始傳輸了. 下面的命令是冪等的,并且 GNU Parallel 完成的作業數應收斂為零. 如果不是這樣,則`all-repos-1234.txt`列出的某些存儲庫在被復制之前可能已被刪除/重命名. ``` # Omnibus sudo -u git sh -c ' cat /var/opt/gitlab/transfer-logs/* | sort | uniq -u |\ /usr/bin/env JOBS=10 \ /opt/gitlab/embedded/service/gitlab-rails/bin/parallel-rsync-repos \ /var/opt/gitlab/transfer-logs/success-$(date +%s).log \ /var/opt/gitlab/git-data/repositories \ /mnt/gitlab/repositories ' # Source cd /home/git/gitlab sudo -u git -H sh -c ' cat /home/git/transfer-logs/* | sort | uniq -u |\ /usr/bin/env JOBS=10 \ bin/parallel-rsync-repos \ /home/git/transfer-logs/success-$(date +%s).log \ /home/git/repositories \ /mnt/gitlab/repositories ` ``` ### Parallel rsync only for repositories with recent activity[](#parallel-rsync-only-for-repositories-with-recent-activity "Permalink") 假設您已經完成了一次在 2015 年 10 月 1 日 12:00 UTC 之后開始的同步. 然后,您可能只想同步*在*那*之后*通過 GitLab 更改的存儲庫. 您可以使用`SINCE`變量告訴`rake gitlab:list_repos`僅打印具有最近活動的存儲庫. ``` # Omnibus sudo gitlab-rake gitlab:list_repos SINCE='2015-10-1 12:00 UTC' |\ sudo -u git \ /usr/bin/env JOBS=10 \ /opt/gitlab/embedded/service/gitlab-rails/bin/parallel-rsync-repos \ success-$(date +%s).log \ /var/opt/gitlab/git-data/repositories \ /mnt/gitlab/repositories # Source cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:list_repos SINCE='2015-10-1 12:00 UTC' |\ sudo -u git -H \ /usr/bin/env JOBS=10 \ bin/parallel-rsync-repos \ success-$(date +%s).log \ /home/git/repositories \ /mnt/gitlab/repositories ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看