How to backup MongoDB database manually in DigitalOcean? Let’s look into the solution in this post. With our DigitalOcean Managed Services, Bobcares assist you with your DigitalOcean queries.
How to backup MongoDB database manually in DigitalOcean?
In DigitalOcean, we backup MongoDB manually using the following steps:
1. S3cmd installation
2. S3cmd setup
3. MongoDB Database backup using S3cmd
S3cmd installation
1. We need to install Python and dependencies first:
apt-get install python3 python3-setuptools curl -y
2. Then download the latest version of S3cmd using the below command:
curl -LO https://github.com/s3tools/s3cmd/releases/download/v2.2.0/s3cmd-2.2.0.tar.gz
3. Now extract the file:
tar -xvzf s3cmd-2.2.0.tar.gz
4. Download the extracted directory by accessing it using the below code:
cd s3cmd-2.2.0 python3 setup.py install
5. Now the tool is installed.
S3cmd setup
1. With the DigitalOcean Access key and Secret key, we can set up the S3cmd tool using the below code:
s3cmd --configure
2. Enter the DigitalOcean Access Key, Secret Key, Region, and Endpoint.
3. We can verify the bucket information using the following command after the setup:
s3cmd info s3://mongodb-dump/
MongoDB Database backup using S3cmd
1. Connect to the MongoDB shell by entering the following command after first logging into the server:
mongo
2. Then find all the databases available:
show dbs
3. Next, use the command below to create a backup of the testdb database located in the /opt directory:
mongodump --db testdb --out /opt/
4. We can run the below code to backup all MongoDB databases:
mongodump --out /opt
5. Then verify all backup databases using the following command:
ls /opt
6. Execute the S3cmd code to copy the testdb database directory to the DigitalOcean Spaces:
tar -czvf - /opt/testdb | s3cmd put - s3://mongodb-dump/testdb.tar.gz
7. To copy the admin directory for all databases to the DigitalOcean Spaces, run the S3cmd command:
tar -czvf - /opt/admin | s3cmd put - s3://mongodb-dump/admin.tar.gz
8. Finally confirm all database backups on the DigitalOcean Spaces using the following command:
s3cmd ls s3://mongodb-dump
We can also log in to the DigitalOcean Spaces and verify the backup files.
[Looking for a solution to another query? We are just a click away.]
Conclusion
The article provides a 3 step method from our Support team to backup the MongoDB database manually in DigitalOcean spaces.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
0 Comments