Move db to another location

Anyway to move the data to another location? My HD almost full and want to move it to another partition.

OS
Distributor ID: Neon
Description: KDE neon User Edition 5.19
Release: 20.04
Codename: focal

Mongo:
db version v4.4.0
Build Info:

{
    "version": "4.4.0",
    "gitVersion": "563487e100c4215e2dce98d0af2a6a5a2d67c5cf",
    "openSSLVersion": "OpenSSL 1.1.1g  21 Apr 2020",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "ubuntu2004",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

Thanks.

Stop mongod.
Move the directory specified by dbPath to new partition.
Update dbPath to point to new location.

How do I get the dbPath. Just move all the files there into new directory?

Thanks.

find mongodb config file
sudo find / -name mongod.conf -print

get dbPath from that file

stop mongodb
service mongod stop

check mongodb is not running
sudo systemctl status mongod

copy all files from dbPath to new dbPath
cp -r old_dbPath new_dbPath

chown of new dbPath
sudo chown -R mongodb:mongodb new_dbPath

change dbPath in mongodb config file to new_dbPath

start mongodb
sudo systemctl start mongod

if everything good after restarting your pc, remove the old dbPath

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.