Database Backups with DevKinsta

DevKinsta is a great way to run WordPress sites locally for testing or development purposes. With a few clicks, you can easily create a fresh WordPress site or pull down an existing site hosting with Kinsta. If you rely on your local development, like myself, then you’ll need to be sure your sites within DevKinsta are being backed up somewhere.

Running a backup application like Backblaze will make sure your DevKinsta site files are safe. If you think that’s enough backup coverage, think again! The databases within DevKinsta are not accessible by the file system and therefore not backed up by default. Let’s resolve this right away by creating the following bash script.

#!/usr/bin/env bash

cd ~/DevKinsta/public

for site in */; do


    if docker exec -u www-data -it devkinsta_fpm bash -c "cd public/${site}; wp core is-installed"; then
        echo "Backing up $site database backup to ~/DevKinsta/public/$site/database-${site}.sql"
        docker exec -u www-data -it devkinsta_fpm bash -c "cd public/${site}; wp db export database-${site}.sql"


Running will loop through the DevKinsta sites and generate a backup for each site. These files can now be picked up by whatever backup method you have in place for your local computer. 💯

The last step is to automate this task through a recurring cron job. Run crontab -e and add 30 09 * * * /home/austin/Scripts/ to the bottom line then save. Run crontab -l to verify the daily script has been added. Now all of your DevKinsta sites will generate a fresh database backup every morning at 9:30am. Be sure to change the timestamp and path to your requirements.