Title: Switch bucket functionality
Last modified: September 23, 2018

---

# Switch bucket functionality

 *  [kkoyan](https://wordpress.org/support/users/kkoyan/)
 * (@kkoyan)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/switch-bucket-functionality/)
 * While setting up our production/staging/develop environments, and some scripts
   that are syncing from production->Staging and production->development, we came
   upon the following puzzles:
    We use a different bucket for each environment. 
   We clone the bucket (So they have the same contents). We can update the public
   urls of the images with a `wp search-replace $OLD_PATH $NEW_PATH --precise --
   skip-columns=guid` But this leaves the `bucket` field of each image still pointing
   to the source bucket.
 * We tried testing updating all occurencies of the old bucket in the database, 
   but this was breaking the sm_cloud param of the meta values (So `wp post meta
   get ID sm_cloud` was returning empty after the brute force replacement).
 * Questions:
    1) Why does each image need to have it’s own bucket declaration, 
   since the system has the bucket option on a site level? 2) Is there any functionality
   for switching bucket of any (or all) images? (Switching all the needed data, 
   without breaking the image, without trying to do any move). 3) Are there any 
   dangers if we leave the `bucket` field as it is, and only change the actual url
   of the image? Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [raywalker](https://wordpress.org/support/users/raywalker/)
 * (@raywalker)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/switch-bucket-functionality/#post-10715356)
 * Further to the above, it seems it’s possible to fix buckets after a move by running
   the Sync command from WP Stateless settings.
 * Is there any way of calling this function in an automation environment – API,
   wp-cli etc?
 *  [maxfenton](https://wordpress.org/support/users/maxfenton/)
 * (@maxfenton)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/switch-bucket-functionality/#post-11053198)
 * (I have this same question, I think.) Why does each image need to have it’s own
   bucket declaration, since the system has the bucket option on a site level?
 *  [Alimuzzaman Alim](https://wordpress.org/support/users/alimuzzamanalim/)
 * (@alimuzzamanalim)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/switch-bucket-functionality/#post-11068355)
 * Hello everyone, sorry for the late replay.
 * 1. Bucket name is used to verify that image is from same bucket when deleting
   the image.
    2. As [@raywalker](https://wordpress.org/support/users/raywalker/)
   suggested, after changing the bucket name just sync all the images again from
   Sync tab. 3. No there aren’t any danger. Just do a sync and everything would 
   be as expected.
 * The image URL isn’t generated dynamically using bucket name, we just get it from
   sm_cloud meta.
 * [@raywalker](https://wordpress.org/support/users/raywalker/) sorry there isn’t
   any automated way yet, but we have plan to build one.
 * [@maxfenton](https://wordpress.org/support/users/maxfenton/) check no 1.
 *  [maxfenton](https://wordpress.org/support/users/maxfenton/)
 * (@maxfenton)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/switch-bucket-functionality/#post-11068693)
 * Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Switch bucket functionality’ is closed to new replies.

 * ![](https://ps.w.org/wp-stateless/assets/icon.svg?rev=1715943)
 * [WP-Stateless - Google Cloud Storage](https://wordpress.org/plugins/wp-stateless/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-stateless/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-stateless/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-stateless/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-stateless/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-stateless/reviews/)

 * 4 replies
 * 4 participants
 * Last reply from: [maxfenton](https://wordpress.org/support/users/maxfenton/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/switch-bucket-functionality/#post-11068693)
 * Status: not resolved