How to move files from Bunny Storage back into WordPress

Over time, you may find it necessary to migrate media files that were previously offloaded to a Bunny Storage Zone back onto your WordPress server. Reasons might include simplifying your setup, regaining direct control over your files, or consolidating your hosting environment. The following guide outlines a safe, step-by-step process to ensure the integrity of your media library and maintain proper website functionality.

Before making changes, always create a full backup of your site’s files and WordPress database. This allows you to restore your site quickly if anything goes wrong.

Step 1: Copy files from bunny storage

The first step involves copying your media files from the Bunny Storage Zone back to your WordPress server. It's crucial to maintain the original directory structure to ensure that WordPress can correctly locate and serve these files.

WordPress automatically generates multiple subsizes of each uploaded image to serve optimized versions based on the context. When copying your files back, ensure you include these subsizes. They are usually named according to the pattern filename-widthxheight.extension. For example, for cat.jpg, you might find subsizes like cat-300x200.jpg and cat-1024x768.jpg.

To identify which subsizes exist for a particular file, use the following SQL query on your WordPress database, replacing 123 with the relevant post ID:

SELECT meta_value FROM wp_postmeta WHERE meta_key = '_wp_attachment_metadata' AND post_id = 123;

 

Step 2: Update WordPress database

After copying the files, you need to update the WordPress database to reflect the change. Specifically, you should remove the _bunnycdn_offloaded entry from the wp_postmeta table for each file you're moving back. This entry indicates that the file was offloaded to Bunny Storage, and removing it tells WordPress the file is now stored locally.

Execute the following SQL query for each file, again replacing 123 with the appropriate post ID:

DELETE FROM wp_postmeta WHERE meta_key = '_bunnycdn_offloaded' AND post_id = 123;

 

Step 3: Repeat for all files

Repeat steps 1 and 2 for each file you wish to move back to your WordPress server. It's important to go through the files individually to ensure that the WordPress database accurately reflects the location and status of each media file.

 

Verify Your Changes

Once you’ve completed the transfer and database updates for all files:

  • Check the Media Library: Confirm that your media files appear correctly in the WordPress Media Library.
  • View on the Front-End: Visit a few pages on your site that use these images to ensure they load properly and look as expected.
  • Clear Caches: If you use a caching plugin or CDN, clear or purge the caches after completing the changes to ensure the updates are reflected on the front-end.

 

Congratulations! You've successfully moved your media files from Bunny Storage back to your WordPress server. Your website should now be serving these files directly from your server, ensuring optimal performance and control over your media assets.

 

Need Help or Encountered Issues?

If you encounter any difficulties or have questions while following this guide, our support team is here to assist you. Please don't hesitate to contact us via support request form for prompt assistance.

Table of Contents

Was this article helpful?
1 out of 10 found this helpful