Book Image

CentOS 7 Server Deployment Cookbook

By : Timothy Boronczyk, IRAKLI NADAREISHVILI
Book Image

CentOS 7 Server Deployment Cookbook

By: Timothy Boronczyk, IRAKLI NADAREISHVILI

Overview of this book

CentOS is derived from Red Hat Enterprise Linux (RHEL) sources and is widely used as a Linux server. This book will help you to better configure and manage Linux servers in varying scenarios and business requirements. Starting with installing CentOS, this book will walk you through the networking aspects of CentOS. You will then learn how to manage users and their permissions, software installs, disks, filesystems, and so on. You’ll then see how to secure connection to remotely access a desktop and work with databases. Toward the end, you will find out how to manage DNS, e-mails, web servers, and more. You will also learn to detect threats by monitoring network intrusion. Finally, the book will cover virtualization techniques that will help you make the most of CentOS.
Table of Contents (18 chapters)
CentOS 7 Server Deployment Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Backing up and restoring a MongoDB database


This recipe teaches you how to back up a MongoDB database using the mongodump utility and restore it using mongorestore.

Getting ready

This recipe requires a running MongoDB server and access to a user account with membership in the userAdmin role.

How to do it...

Follow these steps to back up a MongoDB database:

  1. Connect to MongoDB as a user with membership in the userAdmin role:

    mongo --username admin --password "" admin
    
  2. Create an account with membership in the backup and restore roles to be used for creating and restoring backups:

    db.createUser({
         user: "backupusr",
         pwd: "B@CK&4th",
         roles: [
           { role: "backup", db: "admin" },
           { role: "restore", db: "admin" }
         ]
    })
    
  3. Use mongodump on the command-line to export a MongoDB database:

    mongodump --authenticationDatabase admin --username  backupusr 
           --password "" --db packt
    
  4. To restore a database from the backup made by mongodump, use the mongorestore program:

    mongorestore...