Creating a Database Backup and Restoration¶
In this article
A database backup (also known as a dump) can be created and restored in two ways:
- via command line over SSH,
- via the web interface phpMyAdmin (PMA)
Creating a Backup via Console (SSH)¶
Connect to the server via SSH and run the following command:
Replace username, database_name, password, and backup_file.sql with your own data.
The file backup_file.sql will appear in the current directory on the server — that’s your backup.
Creating a Backup via phpMyAdmin¶
Full database export:¶
- In the left pane of phpMyAdmin select the desired database — a list of its tables will appear.
- Go to the Export tab.
- Click
Go(Exportin newer phpMyAdmin versions) — the database copy file will download to your computer.
Exporting only selected tables:¶
- Select the database on the left.
- Tick the boxes next to the tables you want.
- At the bottom of the page, in the With selected: dropdown, choose Export.
- Make sure the format is SQL, then click
Go(Exportin newer versions). The file will be saved to your computer.
Restoring via Console (SSH)¶
To load the backup into the database, run:
Note
Make sure the database already exists on the server. This command simply streams the data from the file into the specified database.
Restoring the Database via phpMyAdmin¶
- In the left pane select the database into which you want to load data.
- Go to the Import tab.
- Click
Choose Fileand select the downloaded dump. - Other settings (charset, format, etc.) can remain at their defaults.
- Click
Go(Importin newer versions) — the data will be loaded into the database.
Note
phpMyAdmin often struggles with files larger than 1 GB. If your dump is large, it’s better to restore it via the console.