英文:
How do I restore an IBM MongoDB database that I have accidentally deleted
问题
我有一个 IBM Cloud Databases for MongoDB 部署,不小心删除了一些文档。如何恢复丢失的数据?
英文:
I have an IBM Cloud Databases for MongoDB deployment and I have accidentally deleted some documents. How can I restore the lost data?
答案1
得分: 2
IBM Cloud数据库服务会自动每天备份您的数据并保留它们30天。因此,您可以将其中一个备份恢复到新的数据库部署中。之后,您可以找到丢失的文档并将它们放回原始数据库中,或者将应用程序指向新数据库并从那里开始。
您可以使用IBM CLI来执行此操作。您可以从这里安装CLI,然后需要添加云数据库插件:
ibmcloud plugin install cloud-databases
使用以下命令登录IBM Cloud CLI:
ibmcloud login -sso
按照屏幕上的提示进行登录。
然后,您可以列出您帐户中的所有数据库部署:
ibmcloud cdb ls
#Name Location State
#Databases for PostgreSQL-76 us-south inactive
#testelastic eu-gb active
#Databases for MySQL-9j us-south active
#mongo-target eu-gb active
接下来,您可以列出您选择的数据库的所有备份:
ibmcloud cdb backups mongo-target
选择您希望还原的备份,然后使用该还原ID创建一个新的MongoDB实例:
ibmcloud resource service-instance-create mongo-restore databases-for-mongodb standard eu-gb -p '{"backup_id":"crn:v1:bluemix:public:databases-for-mongodb:eu-gb:a/abc123-d2af4a82620b"}'
请记住,如果您想更经常地备份数据库,也可以创建按需备份。
有关IBM Cloud数据库MongoDB的更多文档,可以在这里找到。
英文:
The IBM Cloud Databases service takes automatic daily backups of your data and keeps them for 30 days. So you can restore one of those backups to a new database deployment. After that, you can either find your missing documents and put them back into your original database, or you can point your application to the new database and go from there.
You can do this using the IBM CLI. You can install the CLI from here and you will need to add the cloud databases plugin with:
ibmcloud plugin install cloud-databases
Log into the IBM Cloud CLI with:
ibmcloud login -sso
Follow the on-screen instructions to log in.
You can then list all the database deployments in your account with:
ibmcloud cdb ls
#Name Location State
#Databases for PostgreSQL-76 us-south inactive
#testelastic eu-gb active
#Databases for MySQL-9j us-south active
#mongo-target eu-gb active
You can then list all the backups for your chosen database:
ibmcloud cdb backups mongo-target #Id Type Status Created At
#crn:v1:bluemix:public:databases-for-mongodb:eu-gb:a/abc123-d2af4a82620b scheduled #completed 2023-02-07T15:58:02Z
#crn:v1:bluemix:public:databases-for-mongodb:eu-gb:a/abc123-110596debb85 scheduled #completed 2023-02-06T15:58:03Z
#crn:v1:bluemix:public:databases-for-mongodb:eu-gb:a/abc123-18a9b1426b7c scheduled #completed 2023-02-05T15:58:02Z
Choose your preferred backup to restore and then create a new instance of MongoDB using that restore-id:
ibmcloud resource service-instance-create mongo-restore databases-for-mongodb standard eu-gb -p '{"backup_id":"crn:v1:bluemix:public:databases-for-mongodb:eu-gb:a/abc123-d2af4a82620b"}'
#Creating service instance mongo-restore in resource group default of account IBM as bob@aol.com ....
#OK
#Service instance mongo-restore was created.
#
#Name: mongo-restore
#ID: crn:v1:bluemix:public:databases-for-mongodb:eu-gb:a/abc345::
#GUID: a33ee45202bf9
#Location: eu-gb
#State: provisioning
#Type: service_instance
#Sub Type: Public
#Service Endpoints: public
#Allow Cleanup: false
#Locked: false
#Created at: 2023-02-08T11:45:09Z
#Updated at: 2023-02-08T11:45:11Z
#Last Operation:
# Status create in progress
# Message Started create instance operation
Remember that you can also create On Demand backups if you want to back up your database more regularly.
More documentation on IBM Cloud Databases for MongoDB can be found here
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论