내보내기 작업을 실행할 클라이언트 호스트를 준비하려면 데이터베이스가 있는 AlloyDB 기본 인스턴스에 연결할 수 있는 Compute Engine VM을 만들고 해당 VM에 pg_dump 도구와 Google Cloud CLI를 설치합니다.
인스턴스에 psql 클라이언트 연결의 안내에 따라 적절한 연결과 pg_dump 도구가 설치된 Compute Engine VM을 만듭니다. 이 안내를 따를 때는 생성할 DMP 파일을 수용할 수 있도록 Compute Engine VM에 충분한 로컬 스토리지를 할당해야 합니다.
gcloud CLI를 설치하여 Cloud Storage 버킷에 DMP 파일을 만드는 명령줄 액세스를 제공합니다.
데이터베이스 내보내기
데이터베이스를 DMP 파일로 내보내려면 데이터베이스가 있는 AlloyDB 기본 인스턴스의 IP 주소를 가져온 다음 pg_dump 도구를 사용합니다.
세부정보를 확인하여 데이터베이스가 있는 AlloyDB 기본 인스턴스의 IP 주소를 가져옵니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThis page provides instructions on using the \u003ccode\u003epg_dump\u003c/code\u003e tool to export an AlloyDB database into a custom-format DMP file for later import with \u003ccode\u003epg_restore\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe process requires creating a Cloud Storage bucket, preparing a Compute Engine VM client host with the necessary tools, and then running the \u003ccode\u003epg_dump\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epg_dump\u003c/code\u003e command requires the IP address of the AlloyDB primary instance and database name to perform the database export to the local file system of the client host.\u003c/p\u003e\n"],["\u003cp\u003eAfter exporting, the resulting DMP file must be copied to the previously created Cloud Storage bucket, and then the Compute Engine VM can be deleted.\u003c/p\u003e\n"],["\u003cp\u003eYou must have specific IAM roles, such as AlloyDB Admin or Storage Admin, in your Google Cloud project to perform the database export.\u003c/p\u003e\n"]]],[],null,["# Export a DMP file\n\nThis page describes how to use the `pg_dump` tool to export\nan AlloyDB database to a custom-format, archive DMP file that you\ncan later import using the `pg_restore` tool.\n\nThe procedure to perform the export involves these tasks:\n\n1. [Create a Cloud Storage bucket](#bucket) to store the DMP file in.\n\n2. [Prepare a client host](#prepare-host) to perform the export operation.\n\n3. [Export the database](#export) to the DMP file.\n\n4. [Clean up the resources](#clean-up) created to perform the procedure.\n\n\nBefore you begin\n----------------\n\n- You must have the Owner (`roles/owner`) or Editor (`roles/editor`) basic IAM role in the Google Cloud project you are using, or you must have these predefined IAM roles:\n - AlloyDB Admin (`roles/alloydb.admin`) or AlloyDB Viewer (`roles/alloydb.viewer`)\n - Storage Admin (`roles/storage.admin`)\n - Compute Instance Admin (v1) (`roles/compute.instanceAdmin.v1`)\n\n\u003cbr /\u003e\n\nCreate a Cloud Storage bucket\n-----------------------------\n\n[Create a standard storage, regional storage bucket](/storage/docs/creating-buckets)\nin the project and region where your AlloyDB database is located.\n\nPrepare a client host\n---------------------\n\nTo prepare a client host to perform the export operation, you create a\nCompute Engine VM that can connect to the AlloyDB primary\ninstance where your database is located, and install the `pg_dump` tool and the\nGoogle Cloud CLI on that VM.\n\n1. Follow the instructions\n [Connect a psql client to an instance](/alloydb/docs/connect-psql)\n to create a Compute Engine VM with the proper connectivity and the\n `pg_dump` tool installed. When following these instructions, make sure to\n allocate enough local storage to the Compute Engine VM to\n accommodate the DMP file you will create.\n\n2. [Install the gcloud CLI](/sdk/docs/install) to provide\n command-line access to create the DMP file in the Cloud Storage\n bucket.\n\nExport the database\n-------------------\n\nTo export the database to a DMP file, you get the IP address of the\nAlloyDB primary instance where your database is located and then\nuse the `pg_dump` tool.\n\n1. Get the IP address of the AlloyDB primary instance where your database is located by [viewing its\n details](/alloydb/docs/instance-view).\n2. SSH into the Compute Engine VM. \n\n ### Console\n\n 1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n 2. In the list of virtual machine instances, click **SSH** in the row of the instance you created.\n\n ### gcloud\n\n Use the [`gcloud compute\n ssh` command](/sdk/gcloud/reference/compute/ssh) to connect to the instance you created. \n\n ```\n gcloud compute ssh --project=PROJECT_ID --zone=ZONE VM_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: The ID of the project that contains the instance.\n - \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: The name of the zone in which the instance is located.\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: The name of the instance.\n3. Export the database to a DMP file: \n\n ```\n pg_dump -h IP_ADDRESS -U postgres -F custom \\\n DB_NAME \u003e DMP_FILE_NAME\n ```\n\n You will be prompted to enter the password of the `postgres` user.\n - \u003cvar translate=\"no\"\u003eIP_ADDRESS\u003c/var\u003e: The IP address of the primary instance.\n - `-F custom`: Sets the format of the DMP file to a custom-format archive that you can later import using the `pg_restore` tool.\n - \u003cvar translate=\"no\"\u003eDB_NAME\u003c/var\u003e: The name of the database you want to export.\n - \u003cvar translate=\"no\"\u003eDMP_FILE_NAME\u003c/var\u003e: Provide a file name for the DMP file to create on the client host's local file system.\n\n The above shows a simple `pg_dump` command. For information about\n the wide range of options the command supports, see the\n [PostgreSQL documentation](https://www.postgresql.org/docs/16/app-pgdump.html)\n provides.\n4. Copy the DMP file to the Cloud Storage bucket you created earlier: \n\n ```bash\n gcloud storage cp DMP_FILE_NAME gs://BUCKET_NAME\n ```\n\nClean up resources\n------------------\n\nAfter successfully exporting the DMP file, you can [delete the\nCompute Engine VM](/compute/docs/instances/deleting-instance)\nyou used during the export procedure.\n\nWhat's next\n-----------\n\n- Learn how to [export a CSV file](/alloydb/docs/export-csv-file).\n- Learn how to [export a SQL dump file](/alloydb/docs/export-sql-file)."]]