Error while restoring a backup /var/lib/mysql isn't empty

I have a full backup created by xtrabackup. Now I want to restore this backup to another machine which already has an instance of percona mysql installed.

While trying to restore with xtrabackup --copy-back --target-dir=/data/backups/, I get an error saying /var/lib/mysql isn’t empty. So is it okay to just delete /var/lib/mysql and perform the restore? Is there any other better way? Thanks!

1 Like
systemctl stop mysql
mkdir /tmp/mysql
mv /var/lib/mysql/* /tmp/mysql
xtrabackup --copy-back --target-dir=/data/backups/
chown -R mysql:mysql /var/lib/mysql/
systemctl start mysql

Done :slight_smile:

1 Like

Seems you sorted it out already but yes, it is safe to delete the contents of the data dir if you are going to be restoring from backup

2 Likes