2

I have a backup and restore database menu in my application, here I use sqlite for my database, I want to implement import and export database system like in phpmyadmin, and I am thinking of how to access database.sqlite in the database folder

I have tried it this way

<a href="/database/database.sqlite" class="btn">Backup</a>

and got the error

is there any way to get database.sqlite or maybe an easier way to backup and restore sqlite database on laravel 5.4?

1 Answer 1

2

Since this file is not in public directory, you need to create a symbolic link between the database and public/database directories to make this work:

ln -s /full/path/to/laravel/database /full/path/to/laravel/public/database

Or you can create a controller method and download this file with:

return response()->file(database_path('database.sqlite');

I also want to say that it's terribly insecure way yo backup the database and you should consider getting this file via SSH or something.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, it works fine, but I do not get the name and extension of the file when trying to save it as in the picture image which I expect like this image
@IndraSukmajaya pass file name as the second parameter. There is a link in my answer, you can read more about this by clicking the link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.