Mongodb history of commands in the .dbshell file - mongodb

mongo maintains a history of commands in the .dbshell file.
Where in windows folder can we see this file?

In the user's home directory. <root>\Users\<username>
E.g. C:\Users\Jack

Related

Batch file to archive important files into a zip file in Windows 7

I have some files which I would like to be able to archive daily into a zip file that has the date in the filename.
The files to be archived are in one folder, let's call them a, b and c.
I would like them to be zipped into a file with the name archiveYYYYMMDD.zip into a second (different) folder where YYYYMMDD is the current date. I'm struggling to come up with a suitable batch file.
I'm running Windows 7 x64 Ultimate. I have a scheduling program which would run the batch file at a preset time every day.
Thanks
Alan
This can be done with shareware archiver WinRAR with a single command line:
"%ProgramFiles%\WinRAR\WinRAR.exe" a -afzip -agYYYYMMDD -cfg- -ed -ep1 -ibck -inul -m5 -r -y -- "Path to Backup Folder\Backup_.zip" "Path to Folder to Backup\"
This single command line can be executed directly as scheduled task. There is no need for a batch file.
The help of WinRAR opened by starting WinRAR and clicking in menu Help on menu item Help topics explains under Contents menu item Command line mode the command line syntax, the command a and the used switches.

How to create mask in winrar to archive folders by name?

I have folders C:\testA01, C:\testA02 and C:\testB01, C:\testB02.
How to create a command to archive only folders with testA in their name?
"C:\Program Files\WinRAR\WinRAR.exe" a -r -u -rr8 -y C:\BACKUP\backup.rar C:\testA ?? \*.*
Windows command line interpreter does not support wildcards in folder paths. It is only possible to search for folders matching a pattern with DIR or FOR.
But take a look on text file WhatsNew.txt in program files directory of WinRAR version 5.30 or any later version. There can be read:
Folder wildcards are allowed in RAR command line in file names to
archive. For example:
rar a backup c:\backup\2015*\*
will archive all '2015*' folders in c:\backup. Use -r switch to search
for '2015*' also in c:\backup subfolders.
WinRAR v5.30 can be used on Windows XP and later Windows.
A command line for your backup task is for example:
"%ProgramFiles%\WinRAR\Rar.exe" u -cfg- -ep1 -idq -r -rr8 -y C:\BACKUP\backup.rar C:\testA*\*
For details on the used command u which is like command a with switch -u and the used switches see text file Rar.txt being the manual for the console version Rar.exe of WinRAR.
Of course you can also run from command line the GUI version, but one switch must be changed:
"%ProgramFiles%\WinRAR\WinRAR.exe" u -cfg- -ep1 -ibck -r -rr8 -y C:\BACKUP\backup.rar C:\testA*\*
The switch -ibck for running GUI version in background (minimized to system tray) is used instead of -idq which means for console version to run in quiet mode with only error messages printed into console window.
The commands and switches for the GUI version with some differences to console version are explained in help of WinRAR. Start WinRAR, click in menu Help on menu item Help topics, select tab Contents, open item Command line mode and read the pages listed below this list item.

How to start mongo db on windows

I am new to mongo, and I am trying to install mongo on my windows system. I am following THIS tutorial, but when I do
C:\mongodb\bin\mongod.exe
my CMD gives me this output
2015-04-20T18:53:27.433+0500 I STORAGE [initandlisten] exception in ini
en: 29 Data directory C:\data\db\ not found., terminating
2015-04-20T18:53:27.436+0500 I CONTROL [initandlisten] dbexit: rc: 100
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db.
Create this folder
md \data\db
You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in double quotes,
for example:
C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"
Read more in detail
I fixed the same using :
Create a folder data in
D:\project-workspace\mongodb\data
Then Create another folder db inside data
ie,
D:\project-workspace\mongodb\data\db
Then run the command
mongod --dbpath D:\project-workspace\mongodb\data\db
Make sure you have set environment variable for mongodb else browse C:\Program Files\MongoDB\Server\3.4\bin and then execute this =>
mongod.exe --dbpath E:\workspace\mongodb\data
I also faced the similar problem on windows, moreover, i dont have my environment variable set so i have to go to bin folder and run mongo. Below are the steps i followed
1) I created a folder on my desktop something like "C:\Desktop\data\"
2) In order to use mongo shell, you need to run mongo which is similar to a daemon on unix, so in windows, we can do it by opening a command prompt window and change directory to mongo\bin and run
mongod --dbpath C:\Desktop\data and left it runnning
3) I opened second command prompt window, did a change directory to C:\mongo\bin
and executed mongod, that's it
Because MongoDB does not know the directory DB.
Fixed Work for me.
Step 1: New Folder e.g. Run cmd
mkdir E:\workspace\mongodb\data
Step 2: Move to Root MongoDB path e.g. (cd .../MongoDB/.../bin/)
C:\Program Files\MongoDB\Server\3.4\bin>mongod.exe --dbpath E:\workspace\mongodb\data
Ok.
Also faced the same issue in windows. if --dbpath directory path does not contain spaces, do not include quotes. Removing quotes, when the path does not have space, resolved the issue.

bash: mongodb/bin/mongod : No such file or directory

I'm trying to install and run some basic commands on mongodb from this tutorial (on page 4).
So far,
I've downloaded the a 32-bit zip file from the mongodb download page.
I've unzip the file in the following locations home/user1 then renamed it to mongodb
I've create a folder called data then another one inside called db
I've created a file name mongodb.config containing the path of the folder where I want to store my data, which is mongodb/data/db.
But when I run the command to start the server:
user1#user1-VirtualBox: ~$ mongodb/bin/mongod --dbpath ~mongodb/data/db
I'm getting the following error:
bash: mongodb/bin/mongod : No such file or directory
Am I missing something?
Missing a '/', it should be ~/mongodb/data/db, not '~mongodb/data/db'

How do I clear the command history in the mongo shell

Is there a command to clear the history from within the mongo shell?
There should be a file called .dbshell in your home folder. Just delete it.
MongoDB terminal history is stored inside the ~/.dbshellfile. Just empty the .dbshell file
$ > ~/.dbshell
Versions of Windows mongo.exe earlier than 2.2.0 will save the .dbshell file in the mongo.exe working directory.
You can clear contents on the shell by Ctrl + L
Command history is stored in ~/.dbshell file.
For example, on a Unix-like system:
# Ensure an empty history file
echo "" > ~/.dbshell
# Remove rwx access to the history file
chmod 0 ~/.dbshell
If you're using MongoDB Shell as a standalone package, you will find the shell history file located in ~/.dbshell
If you're using the embedded MongoDB Shell inside MongoDB Compass, you will find the shell history file located in ~/.config/MongoDB Compass/MongoDB Compass/shell-history.json
Just empty the history file