Product images are vital to any Magento 2 store, shaping the customer experience and influencing buying decisions. High-quality visuals can boost engagement and conversions—but they’re also at risk from server crashes, hacks, accidental deletion, or failed migrations.
Unlike product data stored in your database, images are separate files that need their own backup strategy. In this guide, we’ll cover where Magento 2 stores product images, how to back them up, restore them when needed, and follow best practices to keep your store’s visuals safe and your business running smoothly.
Understanding how Magento 2 stores product images
Before you can back up or restore product images, it’s important to know where Magento 2 keeps them and how they’re organized. This will help you avoid missing files or accidentally backing up unnecessary data.
Magento’s media folder structure
Magento stores all product images inside your installation’s pub/media/catalog/product directory.
pub/media/ is the root location for all uploaded media files, including category images, CMS page banners, and product images.
catalog/product is the specific path for product images.
To optimize file storage and prevent too many files from being stored in a single folder, Magento uses a subfolder hashing system. This means that each image is stored inside a set of automatically generated subfolders based on a hash of the file name.
For example:
swift
pub/media/catalog/product/a/b/abc123.jpg
a/b/ are hash-based subfolders created automatically by Magento.
abc123.jpg is your actual product image file.
This structure is handled by Magento automatically—store owners don’t need to manage it manually, but it’s important to know so you can back up the correct folder in its entirety.
You may also need: Best practices to manage the Magento 2 pub/media folder – Discover how to keep your media directory organized, optimized, and clutter-free for better performance and easier backups.
Types of image files in Magento
Magento stores multiple versions of the same product image to serve different display needs:
Original Images – The full-size image uploaded in the backend product page.
Resized Thumbnails – Smaller, optimized versions for category pages, search results, and related products.
Cached Versions – Copies of images generated for faster loading. These are stored inside pub/media/catalog/product/cache.
When backing up images, you can choose to include or exclude cached versions. Cached images can be regenerated by Magento after a restore, so excluding them can reduce backup size. However, keeping them may help speed up your site after a restore.
Preparation before backing up or restoring images
Rushing into a backup or restore without preparation can lead to incomplete files, downtime, or even data loss. Taking a few minutes to prepare will ensure the process is smooth and error-free.
When to schedule backups
Backups should be part of your store’s regular maintenance routine. In addition to automated schedules, run manual backups during key moments:
After major catalog updates, New product uploads, seasonal collections, or large image replacements.
Before site migration – Moving to a new server or hosting provider.
Before running bulk import/export operations, To avoid losing data if something goes wrong.
By timing backups strategically, you ensure you always have a recent, clean copy of your product images ready to restore.
Check file permissions and server access
Before starting, confirm that you have the correct level of access to your server:
FTP/SFTP credentials – Needed for manually downloading or uploading files using tools like FileZilla or WinSCP.
SSH access – Required if you plan to run command-line backups, restore operations, or maintenance mode commands.
Hosting control panel access – Such as cPanel, Plesk, or a cloud hosting dashboard, for file management and compression.
Also, check file permissions for the pub/media/catalog/product directory. If permissions are too restrictive, you might encounter errors when trying to download or restore images. In most cases, directories should have 755 permissions and files 644.
Enable maintenance mode (For restores)
When restoring images, especially on a live store, you want to prevent customer interactions that could lead to errors or inconsistent data. The safest way is to put Magento into maintenance mode:
bash
php bin/magento maintenance:enable
This temporarily disables the storefront and shows a maintenance page to visitors. Once the restore is complete, disable maintenance mode with:
bash
php bin/magento maintenance:disable
This step isn’t necessary for backups, but it’s strongly recommended for any restore operation.
Verify storage capacity for backups
A backup will fail if your server or local storage doesn’t have enough space to hold the image files. Product image folders can grow quickly, especially if you have multiple versions of each file.
If storing locally, make sure your hard drive or backup destination (e.g., external drive, cloud folder) has enough free space.
Consider compressing backups (.zip or .tar.gz) to save storage.
Audit product images before backup
Before you start the backup, review your image library to avoid storing unnecessary or outdated files:
Remove unused product images – Delete files that are no longer linked to any product.
Eliminate duplicates – Identify and remove duplicate images to reduce backup size.
Optimize file formats – Consider converting large PNG or JPG files to WebP using a Magento WebP image extension. This can reduce storage size while maintaining quality.
Check naming consistency – Ensure file names match their linked SKUs or database references to avoid broken image links after a restore.
By auditing your images first, you make backups leaner, faster to create, and easier to restore.
Tip: The Magento 2 WebP by BSS Commerce, a trusted Magento 2 extension provider, can automate image conversion to the WebP format. This not only reduces file sizes without losing quality but also speeds up your site and makes backups more efficient.
Methods to back up product images in Magento 2
Magento 2 gives you multiple options to back up product images, ranging from manual downloads to fully automated cloud solutions. The method you choose depends on your store size, technical skills, and how often you need backups. Below are the most common and reliable methods, with step-by-step guidance for each.
Method 1 – Backup via FTP/SFTP (Manual Download)
Best for: Small to medium stores that need occasional backups without complex tools.
Steps:
Connect to your Magento server using an FTP/SFTP client like FileZilla, Cyberduck, or WinSCP. Navigate to the folder:
bash
pub/media/catalog/productDownload the entire folder to your local computer.
(Optional) Compress the backup into a .zip or .tar.gz file to save space.
Pros:
Simple and beginner-friendly.
No command-line knowledge required.
Cons:
It can be slow for large stores.
Requires manual effort each time.
Method 2 – Backup via hosting control panel (File Manager)
Best for: Store owners with cPanel, Plesk, or similar hosting dashboards.
Steps (cPanel example):
Log in to your hosting control panel.
Open File Manager and go to your Magento root directory.
Locate pub/media/catalog/product.
Compress the folder into a .zip or .tar.gz file directly on the server (faster than downloading uncompressed files).
Download the compressed file to your local machine or store it in the hosting backup section.
Pros:
Faster than FTP for large image sets.
Compression reduces download time.
Cons:
Requires hosting panel access.
Not ideal for automation.
Method 3 – Backup via Command Line (SSH)
Best for: Developers, large stores, or automated workflows.
Steps:
Connect to your server via SSH: Navigate to your Magento root directory:
bash
cd /path/to/magento/rootCreate a compressed backup:
bash
tar -czvf product-images-backup.tar.gz pub/media/catalog/productMove the backup to a secure folder or download it via SFTP.
Automation Tip: You can schedule this command to run automatically using cron jobs:
bash
0 2 * * * tar -czvf /backups/product-images-$(date +\%F).tar.gz /path/to/magento/pub/media/catalog/product
Pros:
Fast, especially for large stores.
Can be fully automated.
Cons:
Requires command-line access and experience.
Method 4 – Backup via Magento admin media backup (If Enabled)
Best for: Stores with built-in backup features enabled in Admin settings.
Steps:
In Magento Admin, go to System → Backups.
Click Media Backup.
Wait for Magento to create the backup file.
Download it from your server’s backup location.
Notes:
This backup includes all media files, not just product images, so file size may be large.
Some Magento installations have backups disabled for performance reasons.
Pros:
No external tools required.
Integrated into Magento Admin.
Cons:
Larger file sizes.
May be disabled on some hosting setups.
Method 5 – Automated backups via extensions or cloud services
Best for: Store owners who want set-it-and-forget-it backups with offsite storage.
Features to Look For:
Scheduling (daily, weekly, monthly).
Offsite storage (Google Drive, Dropbox, AWS S3, etc.).
Incremental backups to save bandwidth and space.
One-click restore options.
Pros:
Hands-off process.
Secure offsite storage.
Cons:
Usually, a paid solution.
Dependent on third-party reliability.
By choosing the right backup method—or combining multiple methods—you can protect your Magento 2 product images from accidental loss and keep your store running smoothly.
How to restore product images in Magento 2
A backup is only as good as your ability to restore it. Whether you’re recovering from accidental deletion, server issues, or migrating to a new environment, restoring product images in Magento 2 is a straightforward process when done correctly. Below are the main methods to bring your images back into place.
Method 1 – Restoring from a backup
This is the most straightforward option if you have a good backup strategy in place. It involves bringing back either the database, the media folder, or both.
1. Restore from a database backup
A database backup contains all product information, including the file paths for base images, thumbnails, and additional images.
Restoring a recent database backup will re-establish these image links, provided the image files themselves are still on the server.
If you have lost the actual image files, combine this step with a media folder restore.
2. Restore from a media Backup
If you’ve lost or deleted product images but still have a backup of the pub/media/catalog/product folder, you can simply upload it back to the same location.
This restores the physical image files so Magento can display them again.
Always match the folder structure exactly to avoid broken links.
3. Automated backup & restore tools
Certain Magento extensions can automate backup and restoration. For example, some “trashcan” or rollback extensions keep temporary copies of deleted CMS blocks, product images, or media files, allowing quick recovery without manual uploads.
Method 2 – Re-importing with a CSV File
If you don’t have a direct backup of your media folder or database, but you do have a CSV product file from a previous export or import, you can use it to relink images.
1. Prepare the CSV File
Ensure the CSV includes image-related columns such as:
base_image
small_image
thumbnail_image
additional_images
The paths in these columns should point to images inside pub/media/import or a valid external URL.
2. Place Image Files in the Import Directory
Upload all the required product images into:
swift
pub/media/import
Make sure file names match exactly with what’s in the CSV file.
3. Re-import the products
In Magento Admin, go to System → Import.
Choose Products as the entity type.
Select the CSV file, set the import behavior to Add/Update, and run the import.
Magento will associate each product SKU with its respective images.
When to use this nethod:
You have the image files, but no direct media folder backup.
You’re restoring only certain products instead of the entire store.
You’re migrating from another site where a CSV export is available.
Tip: If you’re restoring to a new server or staging site, make sure file permissions match Magento’s recommended settings to avoid broken images.
Post-restore actions you shouldn’t skip
Restoring product images in Magento 2 isn’t the final step—there are a few crucial actions you should take to ensure everything displays correctly and your storefront runs smoothly. Skipping these steps can lead to broken thumbnails, outdated caches, or missing images on the frontend.
Clear image cache and regenerate thumbnails
Magento stores resized versions of product images in a cache folder to speed up page loading. After restoring images, these cached versions may be outdated or broken. Clearing the cache forces Magento to regenerate fresh thumbnails.
To remove cached images:
bash
rm -rf pub/media/catalog/product/cache
Then, clear and flush Magento’s cache:
bash
php bin/magento cache:clean
php bin/magento cache:flush
This ensures the storefront displays the most up-to-date versions of your restored images.
Check the frontend for missing or broken images
After clearing the cache, test your store’s frontend to confirm the images are back in place:
Test on both desktop and mobile to ensure images load correctly in responsive layouts.
Use the browser inspector tool (right-click → Inspect) to check the image file paths. If they’re incorrect or point to missing files, you may need to fix them in the database or CSV import.
Browse different product and category pages to ensure thumbnails, zoom images, and swatches appear correctly.
Run reindexing if needed
If you restored product data from a database backup or CSV import along with your images, you might need to reindex Magento’s data so the storefront reflects the updates.
Run the reindex command:
bash
php bin/magento indexer:reindex
Reindexing ensures all catalog and search data aligns with the restored media files, preventing display or search issues.
Continue optimizing images after restoring
Restoring images is just the first step — keeping them optimized afterward ensures your site stays fast and storage-friendly.
Audit new uploads – Check that newly added product images follow the same naming, size, and quality standards as before.
Remove unnecessary cached files – Clear old cached thumbnails that may have been restored but are no longer in use.
Automate WebP conversion – The BSS Commerce WebP extension can also automatically convert newly uploaded product images to the WebP format. This ensures every image you add post-restore is immediately optimized for speed and storage efficiency.
Regularly recheck image size – Use tools or scripts to monitor file sizes and detect oversized images that may need compression.
Tired of broken or blurry product images slowing down your store?
Check out X Common image issues in Magento 2 and how to fix them to uncover the most frequent image problems — and the exact steps to fix them before they hurt your sales.
Best practices for image backup and restore in Magento 2
While knowing how to back up and restore product images is important, having a consistent strategy ensures you never face the panic of missing visuals during a busy sales period. The following best practices will help you maintain a reliable, long-term backup and restore process.
Store backups off-site
Keeping backups only on your Magento server is risky—if the server crashes or gets hacked, you could lose both your live site and your backups. Instead:
Store copies in cloud storage such as Google Drive, Dropbox, or AWS S3.
Keep an external hard drive or secure NAS device for local redundancy.
Use automated tools that sync backups to multiple locations.
Automate and schedule backups
Manual backups are prone to human error and forgetfulness. Set up automation to ensure backups happen consistently:
Use hosting control panel tools or cron jobs for scheduled backups.
Choose a backup frequency that matches your update cycle—daily for high-volume stores, weekly for smaller ones.
Test automated scripts periodically to confirm they’re working.
Keep multiple versions of backups
Don’t rely on a single backup copy. If that file is corrupted or incomplete, you’re out of luck.
Maintain at least three backup versions from different dates.
Rotate backups so you always have a mix of recent and older copies.
For critical sales periods (e.g., Black Friday), take extra backups before making big changes.
Test restores regularly
A backup is only useful if it can be restored successfully.
Periodically test the restore process on a staging environment.
Verify that all product images, paths, and thumbnails display correctly.
Document the restore steps so anyone on your team can perform them in an emergency.
By following these practices, you’ll have a solid safety net for your product images, ensuring they can be quickly recovered without disruption to your business.
Conclusion
Product images are more than just visual assets—they’re a core part of your store’s identity and a critical factor in customer trust and conversion rates. Losing them can disrupt operations, hurt sales, and damage your brand image.
By understanding where Magento 2 stores product images, preparing properly before backups or restores, and using the right methods for each situation, you can recover from any mishap quickly. Pair that knowledge with best practices like offsite storage, automation, and regular restore tests, and you’ll have a reliable safety net for your store’s visuals.
Don’t wait until a problem strikes—set up your backup routine now, so you’re ready to restore your images at a moment’s notice and keep your store looking its best.