4

leanote 数据库(MongoDB)备份以及恢复教程

 2 years ago
source link: https://hellodk.cn/post/866
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

查看 leanote 数据库配置

查看 leanote 安装配置文件 (一般是 /data/leanote/conf/app.conf),找到数据库的用户名和密码(以及端口、数据库名字等信息)

# mongdb
db.host=127.0.0.1
db.port=27017
db.dbname=leanote # required
db.username= # if not exists, please leave it blank
db.password= # if not exists, please leave it blank
# or you can set the mongodb url for more complex needs the format is:
# mongodb://myuser:mypass@localhost:40001,otherhost:40001/mydb
# db.url=mongodb://root:root123@localhost:27017/leanote
# db.urlEnv=${MONGODB_URL} # set url from env. eg. mongodb://root:root123@localhost:27017/leanote

注意,如果没有用户名和密码,就不要后面的 -u=root -p=xxxx,比如上面的配置就没有用户名和密码

mongodump --port 27017 --db leanote -o /data/leanoteBackUp -u=root -p=xxxx

恢复备份的数据使用命令。同样如果没有用户名和密码,就不要后面的 -u=root -p=xxxx,比如上面的配置就没有用户名和密码

# 根据实际使用的路径来改变
mongorestore -h 127.0.0.1:27017 -d leanote /data/leanoteBackUp/leanote -u=root -p=xxxx

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK