Webpage recovery from new API deployment and existing database + backup plan


#1

Hi,

I’ve just learned the hard way the S3 bucket with a name from S3_BUCKET field that is in the api/.env.json will be deleted during the cleanup procedure when I will execute webiny remove-api. This bucket keeps all the pictures on the webpage. However, I found that the database is persistent and all the webpage layout, settings and pictures metadata stays untouched.

I couldn’t successfully reuse the previous database as webiny deploy-api (Webiny developers - please correct me if I’m wrong) will not populate freshly created S3 bucket if the database already exists. Yes, this bucket will stay empty. This makes the Webiny admin panel useless.

In this point I have two questions:

  1. Is it possible to do the recovery using fresh deployment and existing database? (I want to reuse the webpage layout I created before). I know there are bunch of images preloaded into the S3 bucket during deployment.

  2. What would you recommend as a backup plan? Snapshot of the S3 bucket containing pictures, database, something else?

Thanks in advance for your advice!

Regards,
Peter


#2

Hi @Peter_Palka,

I’m sorry you had to experience this, as you said, the hard way :frowning:.

We will implement the most logical change here, we simply won’t delete the bucket upon executing webiny remove-api.

The issue is documented in the following GH issue: https://github.com/webiny/webiny-js/issues/647. I’ll let you know as soon the fix is released, I hope tomorrow.


#3

Hi @Adrian_Smijulj,

Don’t worry about my experience :wink: I’m learning everything by trials and errors. I’m happy my webpage is not live yet so I can break it, have downtimes, repair it and learn how to avoid this situation in the future.

Thanks for taking action. I’m looking forward for the update.

Cheers!
Peter


#4

Hi,

That’s a short description of how to do the webiny recovery after deployment removal. When executing webiny remove-api and webiny remove-apps the database and s3 bucket with media stays untouched.

How to recover Webiny after api/apps deployment removal

(tested on webiny-cli version 2.5.2 and serverless-files version 2.3.3 on MacOS Catalina 10.15.2)

Summary

All you need to do is to deploy new webiny api/apps and modify api URLs in the database.

Useful tools:

Procedure:

  1. Go to your webiny project directory and deploy webiny with webiny deploy-api and webiny deploy-apps.
  2. Note the GraphQL API URL and Your website URL.
  3. In Settings collection of your database find file-manager key and replace data/srcPrefix value with GraphQL API URL (there’s /files/ on the end. Keep it). You can use MongoDB Compass - have a look at the screenshot below.
  4. Also, find page-builder key and replace data/domain value with Your website URL.

#5

Hi @Peter_Palka,

I released a new 2.3.3 version (https://www.npmjs.com/package/@webiny/serverless-files) a few days ago, so when you get a chance, please check it out. Once you upgrade this package in your own project, the S3 bucket won’t be deleted on future webiny remove-api executions.

This is the PR that was merged: https://github.com/webiny/webiny-js/pull/648

Let me know if you’ll have additional qustions.

Thanks!


#6

Hi @Adrian_Smijulj,

Thanks a lot for the update. I can’t test it right now (I’m currently on the road) but as soon as I’ll be able to I will update the recovery procedure.

Regards,
Peter

Edit: looks like it works perfectly now. Thanks a lot!