--- title: "SourceCommit の手動バックアップ" slug: "sourcecommit-use-backup" updated: 2026-09-17T09:23:38Z published: 2026-09-17T09:23:38Z canonical: "guide.ncloud-docs.com/sourcecommit-use-backup" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # SourceCommit の手動バックアップ Classic/VPC環境で利用できます。 SourceCommitのリポジトリは、ユーザーソースコードを安全に保存して復旧できるように構成されています。しかし、ユーザーが誤ってリポジトリを削除すると、コードも削除されて復旧できません。このような状況に備え、SourceCommitを NAVERクラウドプラットフォームの他のサービスと連携して安全にコードをバックアップできます。 参考 - コードバックアップは SourceCommit機能として直接提供しませんが、NAVERクラウドプラットフォームの他のサービスと連携するとバックアップできます。ユーザーの便宜のためにその方法を説明します。 - SourceCommitの作成方法の詳細は、[SourceCommit を開始する](/docs/ja/sourcecommit-start)をご参照ください。 ## Cloud Functionsを通じたバックアップ NAVERクラウドプラットフォームの Cloud Functionsと連携してコードをバックアップする方法を説明します。 ### 1. バックアップする SourceBuild作成 最初に SourceCommitリポジトリをバックアップする SourceBuildプロジェクトを作成します。方法は次の通りです。 1. NAVERクラウドプラットフォームコンソールで、 **Menu** > **All Services** > **Developer Tools** > **SourceBuild** メニューを順にクリックします。 2. SourceBuild画面で **[+ビルドプロジェクト作成]** ボタンをクリックします。 3. ビルド対象としてバックアップが必要な SourceCommitリポジトリを選択します。 4. SourceBuildで管理する ubuntuイメージをビルド環境に選択します。 ![source_commit_use_backup_1_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_1_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 5. 必要に応じてビルドコマンドを設定します。 6. **結果アップロード設定** の**ビルド結果** で**結果保存** をクリックして選択します。 - 全体パスを入力してリポジトリをバックアップするように設定します。 ![source_commit_use_backup_2_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_2_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 1. ビルドプロジェクトの作成を完了します。 ### 2. SourceCommit Webhook作成 SourceCommit Webhookを作成します。方法は次の通りです。 1. バックアップが必要な SourceCommitリポジトリで **Hooks** をクリックします。 2. 新しいウェブフックを作成するには **[作成]** ボタンをクリックします。シナリオに適したイベントタイプと Cloud Functionsを対象タイプに選択します。 ![source_commit_use_backup_6_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_6_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 3. **[トリガー作成]** ボタンをクリックしてトリガーとアクションを作成します。イベント発生時にビルドプロジェクトを開始するアクション例は、次の通りです。 ``` const axios = require('axios'); const CryptoJS = require('crypto-js'); // Signature is the value of `x-ncp-apigw-signature-v2` field in the header. function makeSignature(url, timestamp, accessKey, secretKey) { const space = ' ', newLine = '\n', method = 'POST'; const hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, secretKey); hmac.update(method); hmac.update(space); hmac.update(url); hmac.update(newLine); hmac.update(timestamp); hmac.update(newLine); hmac.update(accessKey); const hash = hmac.finalize(); return hash.toString(CryptoJS.enc.Base64); } // Header is required for authentication to call NAVER Cloud Platform API. function makeHeader(timestamp, accessKey, signKey) { const headers = { 'Content-Type': 'application/json; charset=utf-8', 'x-ncp-apigw-timestamp': timestamp, 'x-ncp-iam-access-key': accessKey, 'x-ncp-apigw-signature-v2': signKey, }; return headers; } /** * Action to start(or stop) server(VPC) instances using Server API * * Input parameters that must be defined as action parameters * @params {string} accessKey: NAVER Cloud Platform account access key used for API authentication * @params {string} secretKey: NAVER Cloud Platform account secret key used for API authentication * @params {string} baseUrl: https://sourcebuild.apigw.ntruss.com * @params {string} apiUrl: `/api/v1/project/{projectId}/build` * * Please refer to the Server API guide for the accurate `baseUrl` and `apiUrl`. */ function startBuildProject(params) { let apiUrlWithParams = params.apiUrl; const url = `${params.baseUrl}${apiUrlWithParams}`; const timestamp = new Date().getTime().toString(); const signKey = makeSignature(apiUrlWithParams, timestamp, params.accessKey, params.secretKey); const headers = makeHeader(timestamp, params.accessKey, signKey); return new Promise((resolve, reject) => { axios .post(url, {}, { headers: headers }) .then(() => resolve({ done: true })) .catch((error) => reject({ done: false, errorMessage: error.response ? error.response.data.message : error.message })); }); } exports.main = startBuildProject; ``` 1. ウェブフックを作成した後、プッシュイベントを発生させて動作を確認します。 参考 Cloud Functionsアクション例の詳しい作成方法は、[Cloud Function のサンプルコード](/docs/ja/docs/cloudfunctions-samplecodes)をご参照ください。 ## SourcePipelineを通じたバックアップ NAVERクラウドプラットフォームの SourcePipelineで提供するトリガー機能を利用して SourceCommitリポジトリをバックアップする SourceBuildプロジェクトを実行できます。 ### 1. バックアップする SourceBuild作成 最初に SourceCommitリポジトリをバックアップする SourceBuildプロジェクトを作成します。方法は次の通りです。 1. NAVERクラウドプラットフォームコンソールで、 **Menu** > **All Services** > **Developer Tools** > **SourceBuild** メニューを順にクリックします。 2. SourceBuild画面で **[+ビルドプロジェクト作成]** ボタンをクリックします。 3. ビルド対象としてバックアップが必要な SourceCommitリポジトリを選択します。 4. SourceBuildで管理する ubuntuイメージをビルド環境に選択します。 ![source_commit_use_backup_1_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_1_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 5. 必要に応じてビルドコマンドを設定します。 6. **結果アップロード設定** の**ビルド結果** で**結果保存** をクリックして選択します。 - 全体パスを入力してリポジトリをバックアップするように設定します。 ![source_commit_use_backup_2_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_2_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 1. ビルドプロジェクトの作成を完了します。 ### 2. バックアップする SourcePipeline作成 SourceCommitで Pushが発生する時、パイプラインが動作して SourceBuildが動作できるように SourcePipelineを作成します。SourcePipelineを通じてユーザーはリポジトリに Pushイベントが発生する度に自動で SourceBuildを実行するように構成できます。この過程でリポジトリのバックアップを自動実行します。方法は次の通りです。 1. NAVERクラウドプラットフォームコンソールで、 **Menu** > **All Services** > **Developer Tools** > **SourcePipeline** メニューを順にクリックします。 2. SourcePipeline画面で **[+パイプライン作成]** ボタンをクリックします。 3. パイプラインの名前を設定します。 4. **[タスク追加]** ボタンをクリックして作成した SourceBuildプロジェクトを追加します。 - プロジェクトを追加する時、関連付け情報が正しいか確認します。 ![source_commit_use_backup_3_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_3_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 1. 追加したタスクの **[+]** ボタンをクリックして先行タスクがあいパイプラインを構成します。 ![source_commit_use_backup_4_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_4_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 2. **Trigger設定** で **Push** をクリックして選択し、リポジトリを設定します。 ![source_commit_use_backup_5_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/source_commit_use_backup_5_ja.png?sv=2026-02-06&spr=https&st=2026-10-26T11%3A47%3A20Z&se=2026-10-26T12%3A47%3A20Z&sr=c&sp=r&sig=X7F5Xh5N5%2BeySmdvAkRfEw8mpDN8KgJKDpxnlrYqwhw%3D) 3. パイプラインの作成を完了します。