fbpx

RPA (Robotic Process Automation) for Database Administartor (DBA)

How to Become an Efficient, Prompt and Successful Database Administrator (DBA)

How to Start and Stop the PostgreSQL Database

AWS

				
					aws rds start-db-instance --db-instance-identifier <instance_name>
				
			
				
					aws rds stop-db-instance --db-instance-identifier <instance_name>

				
			

Linux

				
					--Run as postgresql linux user
pg_ctl start -D <data_directory>

				
			
				
					--Run as postgresql linux user
pg_ctl stop -D <data_directory>

				
			
				
					sudo systemctl start postgresql

				
			
				
					sudo systemctl stop postgresql

				
			

Azure

				
					az login
az postgres server stop --resource-group <resource-group-name> --name <server-name>

				
			
				
					az postgres server start --resource-group <resource-group-name> --name <server-name>

				
			

awscli Command to Find PostgreSQL rds Free and Used Space

To determine the free and used disk space of a PostgreSQL RDS instance using the AWS CLI, you can use the describe-db-instances command and filter the output to show the FreeStorageSpace and AllocatedStorage fields:

				
					aws rds describe-db-instances --query 'DBInstances[*].{ID:DBInstanceIdentifier, Free:FreeStorageSpace, Allocated:AllocatedStorage}' --output table

				
			

This will give you a table with the ID of the RDS instance, the Free disk space in GB, and the Allocated disk space in GB. You can use these values to calculate the used disk space by subtracting the free disk space from the allocated disk space.

How to Resize PostgreSQL rds Disk Size Using awscli commands

To resize the disk size of a PostgreSQL RDS instance using the AWS CLI, you need to follow these steps but before that try to get the used and free space by running these commands from my artical

1.First, stop the RDS instance.

				
					aws rds stop-db-instance --db-instance-identifier <instance_name>

				
			

Modify the RDS instance’s disk size using the modify-db-instance command:

				
					aws rds modify-db-instance --db-instance-identifier <instance_name> --allocated-storage <new_size_in_gb>

				
			

start the instance

				
					aws rds start-db-instance --db-instance-identifier <instance_name>

				
			
Note: The size change will only occur when you stop and start the instance. Also, back up your data before performing any disk size changes.