AWS AmazonRDS: Reorganize RDS PostgreSQL EC2 import steps and add renamed-DB restore
Summary
Restructures the 'Importing data from a PostgreSQL database on an EC2 instance' procedure: cleans up the step list, removes inline pg_restore rename instructions from Step 2, moves the psql/create-database guidance into Step 3 with an explicit createdb example, and adds a new section 'Loading the data into a database with a different name' showing a custom-format pg_dump (-Fc) plus pg_restore into a differently named database.
Security assessment
The diff is a purely procedural/documentation reorganization of database import steps (pg_dump, createdb, pg_restore, snapshots). It does not fix a vulnerability, change permissions, encryption, or network exposure. The only credential-adjacent text ('you can use the master user name and master password to create the database') is pre-existing operational guidance, not a new security control, and no CVE or advisory is referenced.
Evidence
+## Loading the data into a database with a different name
Diff
diff --git a/AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.EC2.md b/AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.EC2.md index 71a2e45..33f99e6 100644 --- a//AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.EC2.md +++ b//AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.EC2.md @@ -7 +7 @@ -Step 1: Create a file using pg_dump that contains the data to loadStep 2: Create the target DB instanceStep 3: Use psql to create the database on the DB instance and load dataStep 4: Create a DB snapshot of the DB instance +Step 1: Create a file using pg_dump that contains the data to loadStep 2: Create the target DB instanceStep 3: Use psql to create the database on the DB instance and load dataStep 4: Create a DB snapshot of the DB instanceLoading the data into a database with a different name @@ -23,0 +24,2 @@ If you have data in a PostgreSQL server on an Amazon EC2 instance and want to mo +These steps load the data into a database that has the same name as the source database. To load the data into a database with a different name, see Loading the data into a database with a different name. + @@ -28 +30 @@ The following sections provide more details on each step listed above. -The `pg_dump` utility uses the COPY command to create a schema and data dump of a PostgreSQL database. The dump script generated by `pg_dump` loads data into a database with the same name and recreates the tables, indexes, and foreign keys. You can use the `pg_restore` command and the `-d` parameter to restore the data to a database with a different name. +The `pg_dump` utility uses the COPY command to create a schema and data dump of a PostgreSQL database. The dump script generated by `pg_dump` loads data into a database with the same name and recreates the tables, indexes, and foreign keys. @@ -39 +41 @@ The following command creates a dump file called mydb2dump.sql for a database ca -Create the target PostgreSQL DB instance using either the Amazon RDS console, AWS CLI, or API. Create the instance with the backup retention setting set to 0 and disable Multi-AZ. Doing so allows faster data import. You must create a database on the instance before you can dump the data. The database can have the same name as the database that is contained the dumped data. Alternatively, you can create a database with a different name. In this case, you use the `pg_restore` command and the `-d` parameter to restore the data into the newly named database. +Create the target PostgreSQL DB instance using either the Amazon RDS console, AWS CLI, or API. Create the instance with the backup retention setting set to 0 and disable Multi-AZ. These settings allow faster data import. @@ -41 +43 @@ Create the target PostgreSQL DB instance using either the Amazon RDS console, AW -For example, the following commands can be used to dump, restore, and rename a database. +## Step 3: Use psql to create the database on the DB instance and load data @@ -42,0 +45 @@ For example, the following commands can be used to dump, restore, and rename a d +You can use the same connection you used to run the pg_dump command to connect to the target DB instance and recreate the database. The database must have the same name as the source database, because the dump script from Step 1 loads the data into a database with that name. Using _psql_ , you can use the master user name and master password to create the database on the DB instance. @@ -44,3 +47 @@ For example, the following commands can be used to dump, restore, and rename a d - pg_dump -Fc -v -h [endpoint of instance] -U [master username] [database] > [database].dump - createdb [new database name] - pg_restore -v -h [endpoint of instance] -U [master username] -d [new database name] [database].dump +First, create the database using `createdb`: @@ -48 +48,0 @@ For example, the following commands can be used to dump, restore, and rename a d -## Step 3: Use psql to create the database on the DB instance and load data @@ -50 +50 @@ For example, the following commands can be used to dump, restore, and rename a d -You can use the same connection you used to run the pg_dump command to connect to the target DB instance and recreate the database. Using _psql_ , you can use the master user name and master password to create the database on the DB instance + createdb --host [endpoint of instance] --port [port] --username [master username] mydb2 @@ -83,0 +84,19 @@ Once you have verified that the data was loaded into your DB instance, we recomm +## Loading the data into a database with a different name + +A plain-text dump loads the data into a database with the same name as the source. To load the data into a database with a different name, create a custom-format dump and restore it with `pg_restore`. + +In place of Step 1, create a custom-format dump. The `-Fc` option is required because `pg_restore` can't read a plain-text dump. + + + pg_dump -Fc -v --host [endpoint of instance] --username [master username] mydb2 > mydb2.dump + +Create the target DB instance as described in Step 2. + +In place of Step 3, create the renamed database and restore into it with `pg_restore`. The following example restores mydb2.dump into a database named mydb3. + + + createdb --host [endpoint of instance] --port [port] --username [master username] mydb3 + pg_restore -v --host [endpoint of instance] --username [master username] --dbname mydb3 mydb2.dump + +Then create a DB snapshot as described in Step 4. +