All Collections
Linux / SSH / Bash
Mass import databases using SSH
Mass import databases using SSH

Run one line in SSH to import all database backups

Justin Catello avatar
Written by Justin Catello
Updated over a week ago

This article assumes a few things before you run the command:

  • You are running the command inside the directory where your backups reside

  • All of the SQL backup files are decompressed and filename ends in .sql

  • The databases have already been created on the server

Run this as one single command:

for dbfile in *.sql
    do
        db=${dbfile//.sql/}

        echo "Importing database: $db from $dbfile"
        mysql "$db" < "$dbfile"
        echo "Done importing $db"
        echo
done
Did this answer your question?