You Can’t.
But in our world this is just a saying. Everything is possible.
Ok, let’s move to explanation. You actually cannot shrink an existing droplet size. That would be going down in price tier and would tear the server apart. Since as they say it actually is not safe because:
Data is not always sequentially written in memory, so reducing the available space would risk data loss and filesystem corruption
I was having a 20$ droplet from times when I was saving audio in colorful barcodes and doing other image heavy processing so I needed more power. Now I just want to keep my DB, learn NextJS and do incremental changes to my Django server. So what can we do?
I was certain that Deploying Existing Snapshots to a new Droplet that would be smaller would be a solution. And after actually cleaning up around 10 GB of my data I was ready but… it is not possible to go back to a smaller droplet size even if the actual disk size fits below new droplet capacity.
So what can we do?
Migrate.
Fortunately in my case it was just deploying the Django App to a new droplet and copying database - I had PostgreSQL with postgis extension.
The scenario I did is not the quickest but safest and easiest to do in my opinion. It is as follows: We use our computer to connect with server1, we make backup, download it to out computer, then we connect to server2 and perform data load.
We need to prepare a couple of things besides the 2 servers we want to migrate the data between.
sudo -u postgres psql
sudo -u your_admin_user pg_dump your_db_name > the_backup.sql
(user should have permissions and ownership over the db)
Create a clean database with:
CREATE DATABASE second_db_name;
Give your user all privilages over it.
GRANT ALL PRIVILEGES ON DATABASE second_db_name TO second_admin_user;
Perform the backup load.
sudo -u second_admin_user psql second_db_name < the_backup.sql
Remember to delete the_backup.sql file from all places afterwards.
Other ways of doing it would be:
Hope it helped. Ping me if you need to know more.
Tell me about your insights and leave a comment - you are most welcome to see more posts of this type just go to home page