September 1st, 2023
In this tutorial, we will guide you through creating a backup of your PlanetScale MySQL database using SimpleBackups. We will cover everything from obtaining your PlanetScale database credentials to creating and restoring backups. By following these steps, you can ensure the safety and security of your valuable data.
You’ll need an active PlanetScale account with a database you have access for. SimpleBackups requires your Connection String, which you can find by going to your PlanetScale’s dashboard, then clicking on the database you want to backup.
Then click on Connect to display your connection string, and copy the connection string displayed bellow
You’ll be greeted by a page where you can connect your database using the connection string, click on Paste in connection string instead, fill in your connection string, uncheck Database Backup Streaming, and check Large Database Backup. then click on Validate Connection.
Select a name for your backup name, set a Schedule and a Storage to store your backup, then click on Create backup.
You’ll be redirected to your backup job’s page, click on Run now to test this backup, once the backup runs successfully, you’ll be able to see a Backup success indicator.
First, locate the URL of your backup, and download it to your local system:
wget 'http://example.com/path/to/your-planetscale-vitess-backup.tar.gz' -O backup.tar.gz
Extract the downloaded file containing your PlanetScale / Vitess MySQL backup:
tar -xzvf backup.tar.gz
Navigate into the extracted directory:
Schema files ending in
-schema.sql can be imported as follows:
for filein *-schema.sql;do mysql -u username -p'password' -h host -P port < "$file" done
Import all other .sql files, excluding the schema files, as data files with these commands:
for filein *.sql;doif [[ ! "$file" == *-schema.sql ]];then mysql -u username -p'password' -h host -P port < "$file" fidone
We’ve gone through the steps to create a PlanetScale MySQL database backup using SimpleBackups. We covered how to grab your PlanetScale's database credentials, create a backup on SimpleBackups, and how to restore your backups. By following these steps, you can ensure that your database is safe and secure.
Free 7-day trial. No credit card required.
Have a question? Need help getting started?
Get in touch via chat or at [email protected]