# Restoring Particular database using Xtrabackup

**URL:** <https://forums.percona.com/t/restoring-particular-database-using-xtrabackup/29255>\
**Category:** Percona XtraBackup\
**Tags:** mysql, percona\
**Created:** [March 20, 2024, 1:20pm UTC](https://forums.percona.com/t/restoring-particular-database-using-xtrabackup/29255 "2024-03-20T13:20:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AK\_Work](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ak_work/32/15733_2.png) [@AK\_Work](https://forums.percona.com/u/AK_Work)\
**Post date:** [March 20, 2024, 1:20pm UTC](https://forums.percona.com/t/restoring-particular-database-using-xtrabackup/29255/1 "2024-03-20T13:20:30Z")

</div>

I have backed up a particular database using the command

```auto
xtrabackup --user=<username> --password=<password> --backup --databases=<database_name> --target-dir=<target-dir-path> 

```

Now to restore, I’ve followed the following steps

- Stop MySQL Server `systemctl stop mysqld.service`
- Delete if any content in `/var/lib/mysql` before restore.
- prepare the mysql backup taken , if not prepared.
- Run the restore command, `xtrabackup --copy-back --target-dir=<path-to-backed-up-data>`
- Change the permission of the directory `/var/lib/mysql` to `mysql` using the command `chown -R mysql:mysql` ( Need **root permission** at system level ),
- Start the mysql server `systemctl start mysqld.service`

Now when I start back the MySQL server, I get an error.

My analysis is that the databases flag passed during the backup command only passed the database\_name directory and not the MySQL and sys databases which store the meta data.  
Due to the absence of these databases, my SQL server is not bought back up correctly.

Is this analysis correct? Are there any other steps to restore a particular database?

Thank you.

---

<div class="post-metadata">

**Author:** ![yunus.uyanik](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/yunus.uyanik/32/19250_2.png) [@yunus.uyanik](https://forums.percona.com/u/yunus.uyanik)\
**Post date:** [March 20, 2024, 1:48pm UTC](https://forums.percona.com/t/restoring-particular-database-using-xtrabackup/29255/2 "2024-03-20T13:48:20Z")

</div>

Hi, thanks for the details, and your assumption is correct.  
Let me quote from the doc:

> The ` –databases` option accepts a space-separated list of the databases and tables to backup in the `databasename[.tablename]` format. In addition to this list, make sure to specify the `mysql`, `sys`, and `performance_schema` databases. These databases are required when restoring the databases using xtrabackup –copy-back.
> 
> ```auto
> $ xtrabackup --databases='mysql sys performance_schema test ...'
> 
> ```

> **[Percona XtraBackup - Create a partial backup](https://docs.percona.com/percona-xtrabackup/innovation-release/create-partial-backup.html#__tabbed_1_3)**
>
> xtrabackup supports taking partial backups when the
> innodb\_file\_per\_table option is enabled.

Best.
