Xtrabackup problem

New user :-1: 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

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

Last, on newer MySQL it does not exist a --restore flag : The xtrabackup command-line options - Percona XtraBackup
Where did you get the “–restore” line from?


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

yeah look good, please check our how to’s Restore full, incremental, compressed backups - Percona XtraBackup

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