Back up two things and you have a real Laravel backup: the files and the database. The files hold your code, uploads and configuration; the database holds your users, orders and content. Copy both to a safe place outside the server, test that the copy actually restores, and you can rebuild the site after almost any disaster.
We have watched too many site owners discover the hard way that their "backup" was only half a backup. Usually the files were copied but the database was forgotten, or the database was exported but nobody kept the .env file. Either way, the site could not be rebuilt. This guide walks through the simple way to do it properly on shared hosting, where you may not have full server access.
What should a Laravel backup actually include?
A Laravel project is not one folder. It is several pieces that live in different places, and a useful backup covers all of them. Miss one piece and the restore turns into a puzzle.
| Piece | Where it lives | Why it matters |
|---|---|---|
| Application code | app/, routes/, resources/, config/ | Your site's logic and views — without it there is no site |
| Public uploads | storage/app/public and public/uploads | User images, documents and product files |
| Database | MySQL, exported as a .sql file | Users, orders, posts and settings |
| .env file | Project root | Database password, app key and mail settings |
| Composer files | composer.json and composer.lock | Lets you reinstall the exact same packages |
Two folders you can safely leave out are vendor/ and node_modules/. Both can be rebuilt from composer.json and package.json, and they are huge — backing them up every time wastes space and time. The same goes for the compiled cache in storage/framework/cache and the log files in storage/logs. Back up the list above, and you have everything that cannot be regenerated.
One file deserves special attention: .env. It is not in version control, it is not in the vendor folder, and it holds your APP_KEY. Without the app key, encrypted data such as stored passwords and session data cannot be read. If you lose .env, you can create a new one, but anything encrypted with the old key is gone. Keep a copy of .env in your backup, somewhere safe.
How do I back up the database on shared hosting?
The database is the part people forget, and it is the part that hurts most to lose. On shared hosting you usually have two easy options: phpMyAdmin or the command line.
In phpMyAdmin, open your database, click Export, choose the Quick method and SQL format, and click Go. The browser downloads a .sql file. That file is a complete copy of every table. It works fine for most small and medium sites. The only real limit is size: very large databases can time out during export, and some hosts cap upload sizes during import as well.
If you have SSH or cPanel's terminal, mysqldump is the better tool. From your project folder or anywhere on the server, run:
mysqldump -u your_username -p your_database > backup-2026-11-30.sql
You will be asked for the password, which you can find in your .env file under DB_PASSWORD. The command writes a plain .sql file you can download. For larger databases, add compression in the same step:
mysqldump -u your_username -p your_database | gzip > backup-2026-11-30.sql.gz
That single change can shrink a backup to a fraction of its size. Whichever method you use, check the file after export. A .sql file should start with table creation statements and end with data inserts. If it is only a few kilobytes when your site has thousands of records, something went wrong — check that you exported the right database, not an empty one.
How do I back up the files?
Files are the easy half, but the method matters. The wrong method either misses hidden files or takes forever.
The simplest way on cPanel is the File Manager: select your project folder, choose Compress, and download the resulting zip. That works, but it is slow for large sites and you have to repeat it by hand every time. It also grabs vendor/ unless you exclude it, which makes the zip far bigger than it needs to be.
From SSH or cPanel's terminal, tar is faster and gives you control over what gets included. This command archives the project while skipping the folders you do not need:
tar --exclude=vendor --exclude=node_modules --exclude=storage/logs -czf site-backup-2026-11-30.tar.gz /home/youruser/yourproject
Then download the .tar.gz file. If your project lives inside public_html, back up the whole project folder, not just public_html — the Laravel code usually sits one level above the public folder, and a backup of public_html alone misses it.
Whatever method you choose, remember the hidden files. Files starting with a dot, like .env, are hidden in File Manager by default. In cPanel's File Manager, turn on "Show Hidden Files" in the settings before you select anything, or your backup will silently miss .env. The same applies to FTP clients: most of them hide dotfiles unless you change a setting.
Where should you store the backup?
A backup that lives on the same server as the site is barely a backup. If the server fails, or the hosting account is suspended, or a bad update deletes the wrong folder, the backup goes down with the site. We have seen all three happen.
The rule is simple: keep at least one copy somewhere else. Download it to your own computer, upload it to a cloud drive, or send it to a second server. Two copies in two places is the minimum that lets you sleep well. One copy on the server for quick restores, one copy off the server for real disasters — that combination covers most situations.
Also think about who can read the backup. A .sql file contains your users' email addresses and hashed passwords. A .env file contains your database password and app key. Do not leave backups sitting in a public folder, and do not email them to yourself unencrypted if you can avoid it. If you must store a backup inside public_html temporarily, delete it as soon as you have downloaded it — and make sure nobody can guess the filename. A file named backup.zip in a public folder will be found.
How do you restore a backup without breaking the site?
A backup you have never restored is a guess, not a backup. We recommend testing the restore at least once, on a subdomain or a local copy, before you ever need it in an emergency. The restore itself has four steps, and the order matters.
- Upload the files and extract them to the project folder, keeping the same folder structure the site had before.
- Create an empty MySQL database in cPanel, plus a database user, and attach the user to the database with all privileges.
- Import the .sql file into the empty database, through phpMyAdmin or with mysql -u username -p database < backup.sql from the terminal.
- Check .env: DB_DATABASE, DB_USERNAME and DB_PASSWORD must match the new database, and APP_KEY must be the old one from the backup.
- Run php artisan config:clear and php artisan cache:clear, then check storage and bootstrap/cache are writable by the web server.
The most common restore mistake is importing the .sql file into a database that already has tables in it. That produces duplicate-table errors and a half-imported database. Always start with an empty database. The second most common mistake is forgetting the storage link: if your site serves uploaded images through the public/storage symlink, recreate it with php artisan storage:link after the restore.
If the restored site shows a 500 error, do not panic — it is almost always config cache or permissions. Our 500 error checklist walks through the usual causes, and the 9 common errors after installing a Laravel script guide covers config cache, .env and permission issues in detail. If the site works but scheduled tasks are missing, check your cron jobs in cPanel — they often need recreating after a restore.
How often should you back up, and can you automate it?
How often depends on how fast your site changes. A site that takes orders every day needs a daily database backup at least. A site that changes once a month can get away with a weekly one. The honest answer is to back up as often as you can afford to lose data: if a daily backup feels right, it is because losing a day of orders would hurt.
Files change less often than the database, so a common setup is a daily database backup and a weekly file backup. The database export is small and quick; the file archive is bigger and slower. Splitting them that way keeps the routine cheap enough that you will actually keep doing it.
On shared hosting, full automation is harder than on a VPS, because you may not have cron access to every tool — but a cPanel cron job can run a small shell script that dumps the database and archives the files, then emails you or copies the result off the server. If that sounds like more work than you want, set a weekly reminder and do it by hand. A manual backup done every week beats an automated backup that was never set up. And whatever routine you choose, write it down: the date, the method, and where the file went. When things go wrong at midnight, that note is worth more than a perfect script you cannot remember.
If you are starting from scratch, our cPanel installation guide covers the full setup from upload to first run. You can also browse the full catalogue — every product ships with full unencrypted source code and an installation guide — and check the licence terms to see what you can build with it. If you get stuck, our support is a real human on WhatsApp at +92 333 4916432, or by email at contact@zqdevelopers.com.