How to downsize your RDS PostgreSQL instance

Recently, I realized that one of my RDS instances’ provisioned storage was much higher than what I was actually using, and there was an opportunity to save costs. I went to the RDS console but realized that you can only increased the provisioned storage for an instance, not reduce it. Next, I tried creating a DB snapshot and restoring it into a smaller storage instance. However, that doesn’t work either.

Finally, the following method, using pgAdmin, worked. Before I get into the details, a little context: I was running metabase (a BI tool) on Elastic Beanstalk, and this particular RDS instance was used for metabase’s internal tables. Now, as I soon realized, metabase’s DB takes up very little storage (my snapshot was less than 1 GB in size), and I had provisioned 100 GB storage! I wanted to bring it down to 20 GB (the minimum on RDS). Following are the steps I followed:

  • Create a new RDS instance with the required 20 GB configuration (let’s call the 100 GB instance as metabase_100gb, and the 20 GB instance as metabase_20gb)
  • Terminate the Elastic Beanstalk environment (this will lead to a downtime, but ensure that no new data is written to metabase_100gb during the transition)
  • Connect both metabase_100gb and metabase_20gb to pgAdmin (you will have to make them temporarily publicly accessible if your pgAdmin is running on a local machine; alternatively, you can do these operations in an EC2 instance in the same VPC as the two instances)
  • Right click on the database of metabase_100gb on pgAdmin, and select ‘Backup’. Enter a file name for the backup and start the process. This will back up your DB onto the machine on which pgAdmin is running.
  • Next, create/select a database in metabase_20gb, and then, right click on that database, and click on ‘Restore’.
  • Select the file saved previously. This will copy the contents of the database of metabase_100gb to the selected database of metabase_20gb.
  • Stop metabase_100gb
  • Restore the elastic beanstalk environment that was terminated
  • Change the Environment variables to now point to the new database instance
  • That’s it. Your RDS instance is now downsized (technically, it is replaced by an instance of lower provisioned storage).
  • Delete the metabase_100gb if you wish to

Note: If you don’t wish to use pgAdmin, you can use the pg_dump and pg_restore utilities.


Note 2: You may get the following error during backup:

pg_dump: error: server version: 14.2; pg_dump version: 13.1

pg_dump: aborting because of server version mismatch

In this case, one easy fix is to upgrade your pgAdmin version to the latest. The pg_dump utility version upgrades in tandem.


I hope you liked this article. For more tutorials on AWS, check out https://iotespresso.com/category/aws/. Also, if you are planning to become a certified AWS Solutions Architect, I’d recommend that you check out this course on Udemy. I took this course and found the lectures to be lucid, to-the-point, and fun. I hope they will help you as well.

Leave a comment

Your email address will not be published.