# How to Create a Database Backup in cPanel

Almost every modern website uses a MySQL database. More popular content management systems, such as WordPress, Magento, Joomla, store all data in a MySQL database. If, for some reason, we want to back up the database, such as a MySQL server update, then it is possible to extract the data stored in the database or to recover the dump in case of a possible error.

#### COMPRESS A FOLDER

After you connect to the server via SSH, you can create a backup by issuing the following command:

```
mysqldump -u user_name -p database_name --single-transaction | gzip -2 > db.sql.gz
```

By issuing the above command, you create a compressed dump with a single transaction token.

<p class="callout info">Of course, it is also possible to make an uncompressed dump, but it will take a lot more time and more space will be spent on dumped content.</p>

```
mysqldump -u user_name -p database_name > db.sql
```

#### EXTRACT AN ARCHIVE

You can do this by issuing the following command

```
gunzip < db.sql.gz | mysql -u user_name -p database_name
```

<p class="callout info">To restore an uncompressed database, use the following command:</p>

```
mysql -u user_name -p database_name < db.sql
```