Home > Net >  Restore the last MySQL backup file in a folder
Restore the last MySQL backup file in a folder

Time:06-10

I need to restore the last Mysql Database file created in the home folder but I am getting an error while trying to run the next command

gunzip < /home/$('ls /home -t | head -1') | mysql -u root -p123456 mydatabase -h localhost

The command runs fine if I replace $('ls -t | head -1') for the name of the backup file, but I need to run this on a CronJob every day.

I keep getting the same error:

-bash: ls /home -t | head -1: No such file or directory

CodePudding user response:

Why would you put the single quotes in your command?

Should work if your replace

/home/$('ls /home -t | head -1') 

with

/home/$(ls /home -t | head -1) 
  • Related