- Ashik Nesin
Vercel is a platform for hosting modern web apps like Next.js. And they provide a lot of services out of the box like storage, databases, etc. They also have a generous free plan.
Let's see how to back up and restore the database in Vercel.
Backup database using pg_dump
We'll be using pg_dump to perform a backup operation.
Make sure that you're using the same version of Postgres locally and also in Vercel platform
Get the connection string from your Vercel dashboard
pg_dump "postgresql://<username>:<password>@example.us-east-1.postgres.vercel-storage.com:5432/verceldb" -F c -b -v -f <backup_file_name>.dump
Restore database using pg_restore
We'll be using
pg_restore which we'll be able to restore the database using the dump that we've created using pg_dump and it comes preinstalled when you install the Postgres server locally.
Just run the following command:
pg_restore -d "postgresql://<username>:<password>@example.us-east-1.postgres.vercel-storage.com:5432/verceldb" <backup_file_name>.dump
--dbname 👉 database name (and also connection string as well)
That's pretty much it.
Fun fact: Vercel DB is powered by Neon.tech
Happy backing up!