# Xtrabackup problem

**URL:** <https://forums.percona.com/t/xtrabackup-problem/28716>\
**Category:** Percona XtraBackup\
**Created:** [February 25, 2024, 7:35pm UTC](https://forums.percona.com/t/xtrabackup-problem/28716 "2024-02-25T19:35:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericwm](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@ericwm](https://forums.percona.com/u/ericwm)\
**Post date:** [February 25, 2024, 7:35pm UTC](https://forums.percona.com/t/xtrabackup-problem/28716/1 "2024-02-25T19:35:31Z")

</div>

New user 👎 Having a problem configuring xtrabackup on the command line - restore fails and after I cannot restart my mysql server.  
Can you please advise whether my scripts is ok . My backup Directory is /Database/ (backup appears here as mysql  
my restore script stops the server and removes the contents of var/lib/mysql so left with empty mysql directory  
This is my script-  
#stop the mysql server  
sudo service mysql stop

#remove the old mysql directory contents  
rm -rf /var/lib/mysql/\*

#restore the mysql directory  
xtrabackup --datadir=/var/lib/mysql/ --login-path=local --restore --target-dir=$BACKUP\_DIR/mysql/

#Set new mysql directory ownership  
chown -R mysql:mysql /var/lib/mysql

#restart the mysql server  
sudo service mysql start

---

<div class="post-metadata">

**Author:** ![CTutte](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ctutte/32/1341_2.png) [@CTutte](https://forums.percona.com/u/CTutte)\
**Post date:** [February 26, 2024, 1:18pm UTC](https://forums.percona.com/t/xtrabackup-problem/28716/2 "2024-02-26T13:18:27Z")

</div>

Hi ericwm,

You need to check the log from xtrabackup to find out if the problem is the backup itself or the script.  
For reference you can check the full backup cycle here: [The Backup Cycle - Full Backups - Percona XtraBackup](https://docs.percona.com/percona-xtrabackup/2.4/backup_scenarios/full_backup.html#creating-a-backup)

Last, on newer MySQL it does not exist a --restore flag : [The xtrabackup command-line options - Percona XtraBackup](https://docs.percona.com/percona-xtrabackup/8.0/xtrabackup-option-reference.html#prepare)  
Where did you get the “–restore” line from?

Regards

---

<div class="post-metadata">

**Author:** ![ericwm](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@ericwm](https://forums.percona.com/u/ericwm)\
**Post date:** [February 26, 2024, 3:05pm UTC](https://forums.percona.com/t/xtrabackup-problem/28716/3 "2024-02-26T15:05:47Z")

</div>

Thanks for the response sorry ‘restore’ was a mistake should have typed --copy-back. apart from this is the rest of the script correct?

---

<div class="post-metadata">

**Author:** ![Mughees\_Ahmed](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mughees_ahmed/32/9028_2.png) [@Mughees\_Ahmed](https://forums.percona.com/u/Mughees_Ahmed)\
**Post date:** [February 27, 2024, 3:17am UTC](https://forums.percona.com/t/xtrabackup-problem/28716/4 "2024-02-27T03:17:22Z")

</div>

yeah look good, please check our how to’s [Restore full, incremental, compressed backups - Percona XtraBackup](https://docs.percona.com/percona-xtrabackup/8.0/restore-a-backup.html#get-expert-help)

---

<div class="post-metadata">

**Author:** ![ericwm](https://avatars.discourse-cdn.com/v4/letter/e/e36b37/32.png) [@ericwm](https://forums.percona.com/u/ericwm)\
**Post date:** [February 28, 2024, 6:30am UTC](https://forums.percona.com/t/xtrabackup-problem/28716/5 "2024-02-28T06:30:50Z")

</div>

Thanks for all the feedback, I finally solved my problem as I had an extra / in my path to my destination directory.
