Avro 파일 형식이나 CSV 파일 형식을 사용하여 Spanner 데이터베이스를 Cloud Storage 버킷으로 내보냅니다.
Avro 파일이나 CSV 파일의 데이터를 새 Spanner 데이터베이스로 가져옵니다.
사용 사례
다음과 같은 사용 사례에 Spanner 가져오기 및 내보내기를 사용할 수 있습니다.
일괄 로드: Spanner에 데이터를 일괄 가져올 수 있습니다.
장기 백업 및 보관처리: 언제든지 데이터베이스를 내보내고 장기 백업이나 보관처리를 할 수 있도록 원하는 Cloud Storage 버킷 위치에 저장할 수 있습니다. 또한 PITR(point-in-time recovery)을 사용하여 특정 이전 타임스탬프에서 데이터베이스를 내보낼 수 있습니다.
복구 속도는 빠르지만 보관 기간이 짧은 재해 복구 기법을 찾고 있으면 백업 또는 PITR(point-in-time recovery)을 사용하는 것이 좋습니다.
개발 또는 테스트 프로젝트에 데이터베이스 복사: 프로덕션 프로젝트에서 데이터베이스를 내보낸 후 통합 테스트나 다른 실험에 사용하도록 개발 또는 테스트 프로젝트로 가져올 수 있습니다.
분석을 위한 수집: 데이터베이스를 내보내 운영 데이터를 BigQuery와 같은 분석 서비스로 일괄 수집할 수 있습니다.
BigQuery는 Cloud Storage 버킷에서 Avro 형식의 데이터를 자동으로 수집할 수 있으므로 운영 데이터를 더욱 간편하게 분석할 수 있습니다.
데이터를 복사하거나 이동하지 않고 Spanner 데이터를 실시간으로 분석하기 위해 BigQuery를 사용하려는 경우에는 대신 Spanner 제휴 쿼리를 사용하면 됩니다.
가져오기와 내보내기 및 백업과 복원 비교
Spanner 가져오기 및 내보내기는 여러 가지 면에서 백업 및 복원과 유사합니다. 다음 표에서는 올바른 방법을 결정하는 데 도움이 되도록 이들 사이의 유사점과 차이점을 설명합니다.
백업 및 복원
가져오기 및 내보내기
데이터 일관성
백업 및 내보낸 데이터베이스 모두 transactional consistency 및 external consistency를 갖습니다.
성능 영향
백업은 인스턴스 성능에 영향을 미치지 않습니다. Spanner는 인스턴스의 서버 리소스를 사용하지 않는 전용 작업을 사용하여 백업을 수행합니다.
내보내기는 데이터베이스 성능에 미치는 영향을 최소화하기 위해 중간 우선순위 태스크로 실행됩니다. 자세한 내용은 태스크 우선순위를 참조하세요.
백업이 생성된 후 리전 간 또는 프로젝트 간 백업이 필요한 경우 다른 리전 또는 프로젝트의 인스턴스에 백업을 복사할 수 있습니다. 그런 다음 새 데이터베이스의 백업에서 동일한 프로젝트의 모든 인스턴스로 복원할 수 있습니다. 복원하려는 인스턴스는 백업이 저장된 인스턴스와 동일한 인스턴스 구성을 가져야 합니다.
내보낸 데이터베이스는 Cloud Storage에 저장되고 데이터는 CSV 또는 Avro를 지원하는 시스템으로 마이그레이션될 수 있습니다.
보관
백업을 최대 1년까지 보관할 수 있습니다.
내보낸 데이터베이스는 Cloud Storage에 저장되며, 기본적으로 삭제되기 전까지 계속 보관됩니다. 수명 주기 및 보관 정책을 맞춤설정할 수 있습니다.
가격 책정
백업은 단위 시간별로 사용된 스토리지를 기준으로 Spanner 프로젝트에 청구됩니다. 자세한 내용은 가격 책정 섹션을 참조하세요.
복원은 복원 및 최적화의 두 작업으로 수행됩니다. 데이터 복사 없이 데이터베이스가 백업을 직접 마운트하기 때문에 복원 작업은 빠른 첫 바이트 소요 시간을 제공합니다. 최적화하는 동안 읽기 대기 시간이 약간 더 높을 수 있지만 복원 작업이 완료된 다음에는 데이터베이스를 사용할 준비가 됩니다. 자세한 내용은 복원 작동 방법을 참조하세요.
가져오기는 속도가 더 느립니다. 모든 데이터가 데이터베이스에 기록될 때까지 기다려야 합니다.
파일 형식 비교
다음 표에서는 Spanner 데이터를 가져오고 내보낼 때 Avro 파일 형식과 CSV 파일 형식 간의 기능 차이를 비교합니다.
기능
Avro 형식
CSV 형식
전체 데이터베이스 가져오기 또는 내보내기
예
아니요
데이터베이스에서 선택한 테이블만 내보내는 기능
예
예
이전에 내보낸 테이블을 가져오는 기능
예
예
이전 타임스탬프에서 내보내기
예
예
Google Cloud CLI를 사용하여 가져오기 또는 내보내기
예
예
Dataflow를 사용하여 가져오기 또는 내보내기
예
예
Spanner를 사용하여 가져오기 또는 내보내기
예
아니요
Avro 파일
Avro 형식으로 내보낼 때 내보낼 테이블 목록을 지정할 수 있습니다. 이 방법으로 내보낸 모든 하위 테이블은 상위 테이블과 함께 제공되어야 합니다.
Spanner는 내보낸 파일의 전체 데이터베이스 스키마를 유지합니다.
Avro 형식에서 가져오는 경우 Spanner는 모든 테이블을 포함하여 내보낸 데이터베이스의 전체 스키마를 다시 만듭니다. 원래 내보내기에 포함된 테이블은 내보낸 모든 데이터를 수신하며 다른 모든 테이블은 비어 있습니다.
Google Cloud 콘솔의 Spanner 페이지에서는 제한된 Avro 형식 가져오기 및 내보내기 옵션을 제공합니다. 예를 들어 네트워크 및 서브네트워크 옵션을 설정할 수 없습니다. 다양한 옵션을 사용하려면 대신 Dataflow를 사용하세요.
Spanner에서는 내보내기 또는 가져오기 도구 사용에 대한 추가 요금을 청구하지 않습니다. 데이터베이스를 Spanner로 가져오는 경우 데이터 스토리지 표준 요금이 청구됩니다. 그러나 다음과 같은 경우 데이터베이스 가져오기 및 내보내기와 관련하여 다른 요금이 청구될 가능성이 있습니다. 자세한 내용은 데이터베이스 내보내기 및 가져오기 가격 책정을 참조하세요.
[[["이해하기 쉬움","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-09(UTC)"],[],[],null,["# Spanner import and export overview\n\nYou can import and export a large amount of data into or out of\nSpanner using any of the following methods:\n\n- Import or export any Spanner database using [Dataflow](/dataflow).\n- Export any Spanner database into a Cloud Storage bucket using either Avro or CSV file formats.\n- Import data from Avro or CSV files into a new Spanner database.\n\n| **Note:** If you export a Spanner database to Cloud Storage, then import it back to Spanner, make sure you import the database into a Spanner instance with the same (or higher-tier) Spanner edition as the source instance. Otherwise, the import might fail. For more information, see the [Spanner editions overview](/spanner/docs/editions-overview).\n\nUse cases\n---------\n\nYou can use Spanner import and export for the following use cases:\n\n- **Bulk loading**: You can import data in bulk into Spanner.\n- **Long-term backup and archiving** : You can export your database at any time\n and store it in a Cloud Storage bucket location of your choice for long-term\n backup or archiving. In addition, you can use [point-in-time\n recovery](/spanner/docs/pitr) to export a database from a specific past timestamp.\n If you are looking for disaster recovery techniques that offer quicker\n restoration but have a shorter retention periods,\n consider using [backups](/spanner/docs/backup)\n or [point-in-time recovery (PITR)](/spanner/docs/pitr).\n\n- **Copying databases to development or test projects**: You can export a\n database from a production project and then import it into your development or\n test project to use for integration tests or other experiments.\n\n- **Ingesting for analytics**: You can export a database to ingest your\n operational data in bulk to analytics services such as BigQuery.\n BigQuery can automatically ingest data in Avro format\n from a Cloud Storage bucket, making it easier for you to run analytics\n on your operational data.\n If you want to use BigQuery for real-time analysis of\n Spanner data without copying or moving the data, you can use\n Spanner federated queries instead.\n\nCompare import and export to back up and restore\n------------------------------------------------\n\nSpanner import and export is similar to back up and restore\nin many ways. The following table describes similarities and differences\nbetween them to help you decide which one to use.\n\nCompare file formats\n--------------------\n\nThe following table compares the capability differences between Avro and CSV\nfile formats when importing and exporting Spanner data.\n\n### Avro files\n\nWhen exporting to Avro format, you can specify a [list of tables to\nexport](/spanner/docs/export#export-subset-tables). Any\n[child tables](/spanner/docs/schema-and-data-model#parent-child_table_relationships)\nexported this way need to be accompanied by their parent tables.\nSpanner maintains the entire database schema in the exported\nfiles.\n\nWhen importing from Avro format, Spanner recreates the exported\ndatabase's whole schema, including all tables. Tables included in the original\nexport receive all their exported data; all other tables remain empty.\n\nThe Spanner page of the Google Cloud console offers limited\nAvro-format import and export options. For example, you can't set network and\nsubnetwork options. For a wider set of options, use\n[Dataflow](/dataflow/docs/overview) instead.\n\n#### Limitations\n\nYou can't export and import [locality groups](/spanner/docs/create-manage-locality-groups)\nto the Avro format.\n\n### CSV files\n\nYou can export only a single Spanner table in the CSV format at\na time. When you export, the schema is not exported, only the data\nis exported.\n\nBefore importing from CSV files, you need to\n[create a JSON manifest](/spanner/docs/import-export-csv#create-json-manifest)\nfile.\n\nPricing\n-------\n\nThere are no additional charges from Spanner for using the\nexport or import tools; you pay the standard rates for data storage when you\nimport a database to Spanner. However, there are other potential\ncharges associated with importing and exporting databases. For more information,\nsee [Database export and import pricing](/spanner/pricing#export-import-pricing).\n\nWhat's next\n-----------\n\n- [Export databases from Spanner to Avro](/spanner/docs/export)\n- [Import Spanner Avro files](/spanner/docs/import)\n- [Import and export data in CSV format](/spanner/docs/import-export-csv)\n- [Import data from non-Spanner databases](/spanner/docs/import-non-spanner)"]]