### Set Up Python Virtual Environment and Install Dependencies Source: https://github.com/bchew/dynamodump/blob/master/README.md Commands to create a Python virtual environment, activate it, install development requirements, and set up pre-commit hooks. ```bash python3 -m venv env source env/bin/activate ``` ```bash pip3 install -r requirements-dev.txt ``` ```bash pre-commit install ``` -------------------------------- ### Install dynamodump using pip Source: https://github.com/bchew/dynamodump/blob/master/README.md Install the dynamodump package using pip. This is the primary method for setting up the tool. ```bash pip install dynamodump ``` -------------------------------- ### Backup and Restore Tables Between Different Environments Source: https://github.com/bchew/dynamodump/blob/master/README.md Transfer backups between environments by using different prefixes for source and destination tables. For example, backing up 'production*' tables to 'development*' tables. ```bash dynamodump -m backup -r us-west-1 -s production* ``` ```bash dynamodump -m restore -r us-west-1 -s production* -d development* ``` -------------------------------- ### Display Help Information Source: https://context7.com/bchew/dynamodump/llms.txt Show all available command-line options and their descriptions. Useful for exploring the tool's capabilities. ```bash dynamodump -h ``` -------------------------------- ### Backup with Archive and S3 Upload Source: https://context7.com/bchew/dynamodump/llms.txt Creates compressed backups and uploads them to a specified S3 bucket. The bucket must exist prior to execution. ```bash # Create tar archive and upload to S3 dynamodump -m backup -r us-east-1 -p my-profile -s testTable -a tar -b my-backup-bucket # Create zip archive and upload to S3 dynamodump -m backup -r us-east-1 -p my-profile -s testTable -a zip -b my-backup-bucket # Backup all tagged tables with compression and S3 upload dynamodump -m backup -r us-east-1 -p my-profile -t Environment=prod -a tar -b my-backup-bucket ``` -------------------------------- ### Inspect backup file structures Source: https://context7.com/bchew/dynamodump/llms.txt View the schema metadata and data item format generated by the backup process. ```bash cat dump/testTable/schema.json # { # "Table": { # "AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "N"}], # "TableName": "testTable", # "KeySchema": [{"KeyType": "HASH", "AttributeName": "id"}], # "ProvisionedThroughput": {"ReadCapacityUnits": 1, "WriteCapacityUnits": 25}, # "TableStatus": "ACTIVE", # "ItemCount": 1, # "TableSizeBytes": 28 # } # } ``` ```bash # Example data file structure (dump/testTable/data/0001.json) # { # "Count": 1, # "Items": [ # {"id": {"N": "1"}, "firstName": {"S": "John"}, "lastName": {"S": "Doe"}} # ], # "ScannedCount": 1 # } ``` -------------------------------- ### Backup and Restore DynamoDB Tables on Local Instance Source: https://github.com/bchew/dynamodump/blob/master/README.md Use these commands to back up and restore DynamoDB tables when running a local DynamoDB instance. Ensure you specify the host and port, along with access keys. ```bash dynamodump -m backup -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a ``` ```bash dynamodump -m restore -r local -s testTable --host localhost --port 8000 --accessKey a --secretKey a ``` -------------------------------- ### Backup All Tables and Restore Only Data Source: https://github.com/bchew/dynamodump/blob/master/README.md Back up all tables in a region and then restore only the data, without recreating the table schema. Use '*' to specify all tables. ```bash dynamodump -m backup -r us-west-1 -s "*" ``` ```bash dynamodump -m restore -r us-west-1 -s "*" --dataOnly ``` -------------------------------- ### Run Dynamodump with Docker Source: https://github.com/bchew/dynamodump/blob/master/README.md This command demonstrates how to run the dynamodump tool using its Docker image. It maps the current directory to /data inside the container, allowing access to backup files. ```bash docker run --rm -it bchew/dynamodump -h ``` -------------------------------- ### Configure Billing Mode Source: https://context7.com/bchew/dynamodump/llms.txt Sets the billing mode for restored tables to either provisioned or on-demand. ```bash # Restore with provisioned billing mode (default) dynamodump -m restore -r us-west-1 -s testTable --billingMode PROVISIONED # Restore with pay-per-request (on-demand) billing dynamodump -m restore -r us-west-1 -s testTable --billingMode PAY_PER_REQUEST ``` -------------------------------- ### Backup and Restore a Single DynamoDB Table Source: https://github.com/bchew/dynamodump/blob/master/README.md Use these commands to back up and restore a specific DynamoDB table in a given region. ```bash dynamodump -m backup -r us-west-1 -s testTable ``` ```bash dynamodump -m restore -r us-west-1 -s testTable ``` -------------------------------- ### Specify Custom Dump Path Source: https://context7.com/bchew/dynamodump/llms.txt Defines a custom directory for storing backup files instead of the default 'dump' folder. ```bash # Backup to custom directory dynamodump -m backup -r us-west-1 -s testTable --dumpPath /path/to/backups # Restore from custom directory dynamodump -m restore -r us-west-1 -s testTable --dumpPath /path/to/backups ``` -------------------------------- ### Backup Single DynamoDB Table Source: https://context7.com/bchew/dynamodump/llms.txt Create a backup of a single DynamoDB table, including schema and data. Backup files are stored locally in the 'dump' directory. ```bash # Backup a single table from AWS DynamoDB dynamodump -m backup -r us-west-1 -s testTable ``` -------------------------------- ### Run with Docker Source: https://context7.com/bchew/dynamodump/llms.txt Executes dynamodump within a Docker container, supporting environment variables for credentials and volume mounting. ```bash # Display help docker run --rm -it bchew/dynamodump -h # Backup using Docker with AWS credentials docker run --rm -it \ -e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \ -e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \ -v $(pwd)/dump:/dump \ bchew/dynamodump -m backup -r us-west-1 -s testTable --dumpPath /dump # Using Amazon ECR Public image docker run --rm -it public.ecr.aws/bchew/dynamodump -h # Using GitHub Packages image docker run --rm -it ghcr.io/bchew/dynamodump -h ``` -------------------------------- ### Configure Custom Throughput Source: https://context7.com/bchew/dynamodump/llms.txt Overrides provisioned throughput settings during operations to improve performance. ```bash # Increase read capacity during backup dynamodump -m backup -r us-west-1 -s testTable --readCapacity 100 # Set write capacity during restore (default is 25) dynamodump -m restore -r us-west-1 -s testTable --writeCapacity 50 # Skip throughput updates entirely dynamodump -m restore -r us-west-1 -s testTable --skipThroughputUpdate ``` -------------------------------- ### Backup and Restore Multiple DynamoDB Tables by Prefix Source: https://github.com/bchew/dynamodump/blob/master/README.md Back up and restore multiple tables by specifying a prefix for table names. The default prefix separator is '*'. ```bash dynamodump -m backup -r us-west-1 -s production* ``` ```bash dynamodump -m restore -r us-west-1 -s production* ``` -------------------------------- ### Backup DynamoDB Tables by Tag, Compress, and Store in S3 Source: https://github.com/bchew/dynamodump/blob/master/README.md Back up DynamoDB tables identified by tags, compress the backup (tar or zip), and store it in a specified S3 bucket. ```bash dynamodump -p profile -r us-east-1 -m backup -a tar -b some_s3_bucket -t TAG_KEY=TAG_VALUE ``` ```bash dynamodump -p profile -r us-east-1 -m backup -a zip -b some_s3_bucket -t TAG_KEY=TAG_VALUE ``` -------------------------------- ### DynamoDB Dump CLI Usage Source: https://github.com/bchew/dynamodump/blob/master/README.md This is the main command-line interface for the dynamodump script. Use it to specify operation mode, S3 bucket, region, table names, and other parameters for backup, restore, or empty operations. ```bash usage: dynamodump.py [-h] [-a {zip,tar}] [-b BUCKET] [-m {backup,restore,empty}] [-r REGION] [--host HOST] [--port PORT] [--accessKey ACCESSKEY] [--secretKey SECRETKEY] [-p PROFILE] [-s SRCTABLE] [-d DESTTABLE] [--prefixSeparator PREFIXSEPARATOR] [--noSeparator] [--readCapacity READCAPACITY] [-t TAG] [--writeCapacity WRITECAPACITY] [--schemaOnly] [--dataOnly] [--noConfirm] [--skipThroughputUpdate] [--dumpPath DUMPPATH] [--billingMode {PROVISIONED,PAY_PER_REQUEST}] [--log LOG] [--limit LIMIT] [-f FILTEROPTION] Simple DynamoDB backup/restore/empty. options: -h, --help show this help message and exit -a {zip,tar}, --archive {zip,tar} Type of compressed archive to create. If unset, don't create archive -b BUCKET, --bucket BUCKET S3 bucket in which to store or retrieve backups. [must already exist] -m {backup,restore,empty}, --mode {backup,restore,empty} Operation to perform -r REGION, --region REGION AWS region to use, e.g. 'us-west-1'. Can use any region for local testing --host HOST Host of local DynamoDB. This parameter initialises dynamodump for local DynamoDB testing [required only for local] --port PORT Port of local DynamoDB [required only for local] --accessKey ACCESSKEY Access key of local DynamoDB [required only for local] --secretKey SECRETKEY Secret key of local DynamoDB [required only for local] -p PROFILE, --profile PROFILE AWS credentials file profile to use. Allows you to use a profile instead accessKey, secretKey authentication -s SRCTABLE, --srcTable SRCTABLE Source DynamoDB table name to backup or restore from, use 'tablename*' for wildcard prefix selection or '*' for all tables. Mutually exclusive with --tag -d DESTTABLE, --destTable DESTTABLE Destination DynamoDB table name to backup or restore to, use 'tablename*' for wildcard prefix selection (defaults to use '-' separator) [optional, defaults to source] --prefixSeparator PREFIXSEPARATOR Specify a different prefix separator, e.g. '.' [optional] --noSeparator Overrides the use of a prefix separator for backup wildcard searches [optional] --readCapacity READCAPACITY Change the temp read capacity of the DynamoDB table to backup from [optional] -t TAG, --tag TAG Tag to use for identifying tables to back up. Mutually exclusive with srcTable. Provided as KEY=VALUE --writeCapacity WRITECAPACITY Change the temp write capacity of the DynamoDB table to restore to [defaults to 25, optional] --schemaOnly Backup or restore the schema only. Do not backup/restore data. Can be used with both backup and restore modes. Cannot be used with the --dataOnly [optional] --dataOnly Restore data only. Do not delete/recreate schema [optional for restore] --noConfirm Don't ask for confirmation before deleting existing schemas. --skipThroughputUpdate Skip updating throughput values across tables [optional] --dumpPath DUMPPATH Directory to place and search for DynamoDB table backups (defaults to use 'dump') [optional] --billingMode {PROVISIONED,PAY_PER_REQUEST} Set billing mode between PROVISIONED|PAY_PER_REQUEST (defaults to use 'PROVISIONED') [optional] --log LOG Logging level - DEBUG|INFO|WARNING|ERROR|CRITICAL [optional] --limit LIMIT Limit option for backup, will stop the back up process after number of backed up items reaches the limit [optional] -f FILTEROPTION, --filterOption FILTEROPTION Filter option for backup, JSON file of which keys are ['FilterExpression', 'ExpressionAttributeNames', 'ExpressionAttributeValues'] ``` -------------------------------- ### Backup with Filter Expression Source: https://context7.com/bchew/dynamodump/llms.txt Filters data during backup using a JSON file containing expression attributes. ```bash # Create filter option file cat > filter.json << 'EOF' { "FilterExpression": "#status = :status", "ExpressionAttributeNames": {"#status": "status"}, "ExpressionAttributeValues": {":status": {"S": "active"}} } EOF # Backup with filter dynamodump -m backup -r us-west-1 -s testTable -f filter.json ``` -------------------------------- ### Configure dynamodump logging levels Source: https://context7.com/bchew/dynamodump/llms.txt Adjust the verbosity of the CLI output using the --log flag. ```bash dynamodump -m backup -r us-west-1 -s testTable --log DEBUG ``` ```bash dynamodump -m backup -r us-west-1 -s testTable --log WARNING ``` -------------------------------- ### Backup Multiple Tables with Wildcard Source: https://context7.com/bchew/dynamodump/llms.txt Backup multiple DynamoDB tables that match a specified wildcard pattern. Supports custom prefix separators and disabling the separator. ```bash # Backup all tables starting with "production-" dynamodump -m backup -r us-west-1 -s "production*" ``` ```bash # Backup all tables in the region dynamodump -m backup -r us-west-1 -s "*" ``` ```bash # Use a custom prefix separator (e.g., ".") dynamodump -m backup -r us-west-1 -s "production*" --prefixSeparator "." ``` ```bash # Disable prefix separator for wildcard searches dynamodump -m backup -r us-west-1 -s "production*" --noSeparator ``` -------------------------------- ### Local DynamoDB Operations Source: https://context7.com/bchew/dynamodump/llms.txt Performs operations against local DynamoDB instances by specifying host and credentials. ```bash # Start DynamoDB Local with Docker Compose docker-compose up -d # Backup from local DynamoDB dynamodump -m backup -r local -s testTable \ --host localhost \ --port 8000 \ --accessKey a \ --secretKey a # Restore to local DynamoDB dynamodump -m restore -r local -s testTable \ --host localhost \ --port 8000 \ --accessKey a \ --secretKey a # Empty local table dynamodump -m empty -r local -s testTable \ --host localhost \ --port 8000 \ --accessKey a \ --secretKey a ``` -------------------------------- ### Restore from S3 Backup Source: https://context7.com/bchew/dynamodump/llms.txt Download and restore DynamoDB tables from backups stored in an S3 bucket. Supports both tar and zip archive formats. ```bash # Restore from tar archive in S3 dynamodump -m restore -r us-east-1 -p my-profile -a tar -b my-backup-bucket -s source_table -d destination_table ``` ```bash # Restore from zip archive in S3 dynamodump -m restore -r us-east-1 -p my-profile -a zip -b my-backup-bucket -s source_table -d destination_table ``` -------------------------------- ### Backup DynamoDB Tables Based on AWS Tag Source: https://github.com/bchew/dynamodump/blob/master/README.md Perform a backup of all DynamoDB tables that are tagged with a specific key-value pair in a given region. ```bash dynamodump -p profile -r us-east-1 -m backup -t KEY=VALUE ``` -------------------------------- ### Restore Multiple Tables with Prefix Mapping Source: https://context7.com/bchew/dynamodump/llms.txt Restore multiple DynamoDB tables, optionally renaming them using prefix mapping. Useful for cross-environment migrations. ```bash # Restore all production tables dynamodump -m restore -r us-west-1 -s "production*" ``` ```bash # Restore production tables to development environment dynamodump -m restore -r us-west-1 -s "production*" -d "development*" ``` ```bash # Restore all tables, data only (keep existing schema) dynamodump -m restore -r us-west-1 -s "*" --dataOnly ``` -------------------------------- ### Dump and Restore DynamoDB Table Schemas Only Source: https://github.com/bchew/dynamodump/blob/master/README.md Export only the schema definitions of all tables and then restore these schemas to create blank tables. This is useful for setting up tables in a different AWS account. ```bash dynamodump -m backup -r us-west-1 -p source_credentials -s "*" --schemaOnly ``` ```bash dynamodump -m restore -r us-west-1 -p destination_credentials -s "*" --schemaOnly ``` -------------------------------- ### AWS Profile Authentication Source: https://context7.com/bchew/dynamodump/llms.txt Uses named profiles from the AWS credentials file for authentication. ```bash # Backup using named profile dynamodump -m backup -r us-west-1 -p production-profile -s testTable # Restore using different profiles for source and destination dynamodump -m backup -r us-west-1 -p source-profile -s "*" --schemaOnly dynamodump -m restore -r us-west-1 -p destination-profile -s "*" --schemaOnly ``` -------------------------------- ### Restore Single DynamoDB Table Source: https://context7.com/bchew/dynamodump/llms.txt Restore a DynamoDB table from a local backup. Supports restoring to the same or a different table name and unattended restores with --noConfirm. ```bash # Restore a table with the same name dynamodump -m restore -r us-west-1 -s testTable ``` ```bash # Restore to a different table name dynamodump -m restore -r us-west-1 -s testTable -d newTestTable ``` ```bash # Restore without confirmation prompt (for automation) dynamodump -m restore -r us-west-1 -s testTable --noConfirm ``` -------------------------------- ### Empty DynamoDB Tables Source: https://context7.com/bchew/dynamodump/llms.txt Deletes and recreates tables to clear data while maintaining schema and capacity settings. ```bash # Empty a single table dynamodump -m empty -r us-west-1 -s testTable # Empty multiple tables matching pattern dynamodump -m empty -r us-west-1 -s "test*" ``` -------------------------------- ### Data-Only Restore Source: https://context7.com/bchew/dynamodump/llms.txt Restore only the data for DynamoDB tables, preserving the existing table schema. Useful when the target table already exists. ```bash # Restore data only, preserving existing schema dynamodump -m restore -r us-west-1 -s testTable --dataOnly ``` ```bash # Restore all tables data only dynamodump -m restore -r us-west-1 -s "*" --dataOnly ``` -------------------------------- ### DynamoDB Dump Docker Image Registries Source: https://github.com/bchew/dynamodump/blob/master/README.md These are the container image names for dynamodump available on different container registries. Use these to pull and run the Docker image. ```bash public.ecr.aws/bchew/dynamodump ``` ```bash ghcr.io/bchew/dynamodump ``` -------------------------------- ### Limit Backup Items Source: https://context7.com/bchew/dynamodump/llms.txt Restricts the number of items processed during a backup operation. ```bash # Backup only the first 1000 items dynamodump -m backup -r us-west-1 -s testTable --limit 1000 ``` -------------------------------- ### Backup Tables by AWS Tag Source: https://context7.com/bchew/dynamodump/llms.txt Backup DynamoDB tables identified by specific AWS resource tags. Supports archiving to tar format and uploading backups to S3. ```bash # Backup all tables with a specific tag dynamodump -m backup -r us-east-1 -p my-profile -t Environment=production ``` ```bash # Backup tables with tag and compress to tar archive dynamodump -m backup -r us-east-1 -p my-profile -t Project=myapp -a tar ``` ```bash # Backup with tag and upload to S3 dynamodump -m backup -r us-east-1 -p my-profile -t Backup=daily -a tar -b my-backup-bucket ``` -------------------------------- ### Schema-Only Backup Source: https://context7.com/bchew/dynamodump/llms.txt Backup only the schema of DynamoDB tables without including data. Useful for creating table structures in different environments. ```bash # Backup schema only dynamodump -m backup -r us-west-1 -s testTable --schemaOnly ``` ```bash # Backup all table schemas using source credentials dynamodump -m backup -r us-west-1 -p source_credentials -s "*" --schemaOnly ``` ```bash # Restore schema only to another account dynamodump -m restore -r us-west-1 -p destination_credentials -s "*" --schemaOnly ``` -------------------------------- ### Restore DynamoDB Table from S3 Bucket Source: https://github.com/bchew/dynamodump/blob/master/README.md Restore a DynamoDB table from an archive file stored in an S3 bucket. The 'source_table' parameter identifies the archive file within the bucket. ```bash dynamodump -a tar -b some_s3_bucket -m restore -r us-east-1 -p profile -d destination_table -s source_table ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.