0

I am getting the databases from mysql and my database name is username_something. I am getting the username and then puting the respective backups in corresponding folders like

tar bala bla  /backups/sql/username/username_something.tar.sql.gz

The problem is system worrks if i have the folder username already there but for new databases if get the error like unknown file path.

How can i do that if username folder is not there it should be created

2 Answers 2

2

You can use mkdir before the tar command to create the directory. If multiple dirs in the path may be missing, you can use the -p flag. Using -p will also suppress the error if the directory already exists.

1
mkdir -p /backups/sql/username && tar ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .