MongoDB's full-database backup is also restored from the original single-table collection backup, mongodb single-Table backup

Source: Internet
Author: User
Tags mongodb server mongodump mongorestore

MongoDB's full-database backup is also restored from the original single-table collection backup, mongodb single-Table backup

MongoDB full-database backup and original single table collection backup and Restoration

Cd D: \ MongoDB \ bin

 

1 full-Database Backup:

Mongodump-h dbhost-d dbname-o dbdirectory

-H: the address of the MongDB server, for example, 127.0.0.1: 27017.

-D: The database instance to be backed up, for example, wlwdb

-O: The storage location of the backup data, for example, D: \ MongoDB \ data \ dump. Of course, this directory must be created in advance. After the backup is complete, the system automatically creates a wlwdb directory under the dump directory, which stores the backup data of the database instance.

Eg:

Mongodump-h 127.0.0.1-d wlwdb-o D: \ MongoDB \ data \ dump


You can view the backup directory:


Mongodump -- help


Mongodump official description: options: -- help produce help message-v [-- verbose] be more verbose (include multiple times for more verbosity e.g. -vvvvv) -- version print the program's version and exit-h [-- host] arg mongo host to connect to (/s1, s2 for sets) -- port arg server port. can also use -- host hostname: port -- ipv6 enable IPv6 support (disabled by default) -u [-- username] arg username-p [-- password] arg password -- dbpath arg directly access your D database files in the given path, instead of connecting to a temporary D server-needs to lock the data directory, so cannot be used if a temporary D is currently accessing the same path -- directoryperdb if dbpath specified, each db is in a separate directory -- journal enable journaling-d [-- db] arg database to use-c [-- collection] arg collection to use (some commands) -o [-- out] arg (= dump) output directory or "-" for stdout-q [-- query] arg json query -- oplog Use oplog for point-in-time snapshotting -- repair try to recover a crashed database -- forceTableScan force table scan (do not use $ snapshot)

2 full-database recovery:

Mongorestore-h dbhost-d dbname-directoryperdb dbdirectory

-H: Address of the MongoDB Server

-D: The database instance to be restored, for example, wlwdb (which may be different from the backup)

-Directoryperdb: Location of the backup data, for example, D: \ MongoDB \ data \ dump \ wlwdb

-Drop: When restoring, the current data is deleted first, and then the backup data is restored.

Eg:

Mongorestore-h 127.0.0.1-d wlwdb-directoryperdb D: \ MongoDB \ data \ dump \ wlwdb

 

Mongorestore official instructions (you can view through mongorestore -- help): options: -- help produce help message-v [-- verbose] be more verbose (include multiple times for more verbosity e.g. -vvvvv) -- version print the program's version and exit-h [-- host] arg mongo host to connect to (/s1, s2 for sets) -- port arg server port. can also use -- host hostname: port -- ipv6 enable IPv6 support (disabled by default) -u [-- username] arg username-p [-- password] arg password -- dbpath arg directly access your D database files in the given path, instead of connecting to a temporary D server-needs to lock the data directory, so cannot be used if a temporary D is currently accessing the same path -- directoryperdb if dbpath specified, each db is in a separate directory -- journal enable journaling-d [-- db] arg database to use-c [-- collection] arg collection to use (some commands) -- objcheck validate object before inserting -- filter arg filter to apply before inserting -- drop each collection before import -- oplogReplay replay oplog for point-in-time restore -- oplogLimit arg exclude oplog entries newer provided timestamp (epoch [: ordinal]) -- keepIndexVersion don't upgrade indexes to newest version -- noOptionsRestore don't restore collection options -- noIndexRestore don't restore indexes -- w arg (= 1) minimum number of replicas per write

3 single collection backup:

Export export-h dbhost-d dbname-c collectionname-f collectionKey-o dbdirectory

-H: Address of the MongoDB Server

-D: database instance to be restored

-C: set to be restored

-F: fields to be exported (all fields are omitted)

-O: indicates the exported file name.

 

Official description of volume export (you can view it through volume export -- help): -- help produce help message-v [-- verbose] be more verbose (include multiple times for more verbosity e.g. -vvvvv) -- version print the program's version and exit-h [-- host] arg mongo host to connect to (/s1, s2 for sets) -- port arg server port. can also use -- host hostname: port -- ipv6 enable IPv6 support (disabled by default) -u [-- username] arg username-p [-- password] arg password -- dbpath arg directly access your D database files in the given path, instead of connecting to a temporary D server-needs to lock the data directory, so cannot be used if a temporary D is currently accessing the same path -- directoryperdb if dbpath specified, each db is in a separate directory -- journal enable journaling-d [-- db] arg database to use-c [-- collection] arg collection to use (some commands) -f [-- fields] arg comma separated list of field names e.g. -f name, age -- fieldFile arg file with fields names-1 per line-q [-- query] arg query filter, as a JSON string -- csv export to csv instead of json-o [-- out] arg output file; if not specified, stdout is used -- jsonArray output to a json array rather than one object per line-k [-- slaveOk] arg (= 1) use secondaries for export if available, default true -- forceTableScan force a table scan (do not use $ snapshot)

4. Restore a single collection:

Export Import-d dbhost-c collectionname-type csv-headerline-file

-Type: Specifies the format of the file to be imported.

-Headerline: do not import the first line because the first line is the column name.

-File: Specifies the path of the file to be imported.


Official description of volume import (you can view it through volume import -- help): -- help produce help message-v [-- verbose] be more verbose (include multiple times for more verbosity e.g. -vvvvv) -- version print the program's version and exit-h [-- host] arg mongo host to connect to (/s1, s2 for sets) -- port arg server port. can also use -- host hostname: port -- ipv6 enable IPv6 support (disabled by default) -u [-- username] arg username-p [-- password] arg password -- dbpath arg directly access your D database files in the given path, instead of connecting to a temporary D server-needs to lock the data directory, so cannot be used if a temporary D is currently accessing the same path -- directoryperdb if dbpath specified, each db is in a separate directory -- journal enable journaling-d [-- db] arg database to use-c [-- collection] arg collection to use (some commands) -f [-- fields] arg comma separated list of field names e.g. -f name, age -- fieldFile arg file with fields names-1 per line -- ignoreblks if given, empty fields in csv and tsv will be ignored -- type arg type of file to import. default: json (json, csv, tsv) -- file arg file to import from; if not specified stdin is used -- drop collection first -- headerline CSV, TSV only-use first line as headers -- upsert insert or update objects that already exist -- upsertFields arg comma-separated fields for the query part of the upsert. you shoshould make sure this is indexed -- stopOnError stop importing at first error rather than continuing -- jsonArray load a json array, not one item per line. currently limited to 16 MB.



When the SQL database restoration problem occurs, there is a database backup restoration prompt that both 2000 and 2005 are the same @@

This error indicates that the database version is inconsistent. Are you restoring the data backed up from the SQLServer2008/2005 database to the SQLServer2000 database? First, ensure the connection to the database server. Secondly, the restored backup and the devices to be restored are both SQL2005. SQL data backup cannot be used in MySQL 2008 and MySQL 2000. If both sqlserver2000 and sqlserver2005 are installed in the system, the above error may occur during restoration. Solution: Database properties-options-Compatibility Level-> sqlsever2000 (80 ), either sqlserver2000 or sqlserver2005 are specified during installation. Ask questions if you have any questions.

How Does Oracle back up and restore databases?

1. export/import (export/import)

---- Export can be used to extract data from the database, and import can be used to send the extracted data back to the oracle database.

---- 1. Simple export of data (export) and import of data (import)

---- Oracle supports three types of output:

---- (1) Export the data of the specified table in the table (t) mode.

---- (2) user mode (u mode): exports all objects and data of the specified user.

---- (3) full database (full): export all objects in the database.

---- The data export process is the inverse process of the data import (export). Their data flows are different.

---- 2. incremental Export/Import

---- Incremental export is a common data backup method. It can only be implemented for the entire database and must be exported as a system. During this export, the system does not require any answers. The default export file name is export. dmp. If you do not want your output file to be named export. dmp, you must specify the file name to use in the command line.

---- Incremental export includes three types:

---- (1) "complete" incremental Export (complete)

---- Back up the entire database, for example:

---- $ Exp system/manager inctype = complete file = 990702.dmp

---- (2) incremental Export

---- Back up the data changed after the last backup. For example:

---- $ Exp system/manager inctype = incremental file = 990702.dmp

---- (3) cumulative)

---- The accumulative export method only exports the changed information in the database after the last "full" export. For example:

---- $ Exp system/manager inctype = cumulative file = 990702.dmp

---- The database administrator can schedule a backup schedule and export data in three different ways to achieve reasonable and efficient completion.

---- For example, the database backup task can be arranged as follows:

---- Monday: full export ()

---- Tuesday: Incremental Export (B)

---- Wednesday: Incremental Export (c)

---- Thursday: Incremental Export (d)

---- Friday: accumulative Export (e)

---- Saturday: Incremental Export (f)

---- Sunday: Incremental Export (g)

---- If the database is accidentally damaged on Sunday, the database administrator can follow these steps to restore the database:

---- Step 1: Use the create database Command to regenerate the database structure;

---- Step 2: create an additional return segment that is large enough.

---- Step 3: import a in full Increments:

---- $ Imp system./manager inctype = rectore full = y file =

---- Step 4: Accumulative incremental import e:

---- $ Imp system/manager inctype = rectore full = y file = e

---- Step 5: import the latest incremental f:

---- $ Imp system/manager inctype = restore full = y file = f

---- II. Cold backup

---- Cold backup occurs when the database is shut down normally. When the database is shut down normally, it will provide us with a complete database. Cold backup is a method of copying key files to another location... the remaining full text>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.