阻止 mongodump 覆盖现有文件(改为重命名)
Stop mongodump from overwriting existing files (rename instead)
来自 mongodocs:
覆盖文件
"Mongodump overwrites output files if they exist in the backup data folder. Before running the mongodump command multiple times, either ensure that you no longer need the files in the output folder (the default is the dump/ folder) or rename the folders or files."
大家好,
我想每天做一次备份,有时甚至一天做两次备份。转储文件名按实际日期命名。如果我每天备份两次,第一个备份会因名称相同而被覆盖。
如果文件已经存在,有什么方法可以告诉 mongodump 重命名(例如 5.9.2016(1))文件?
可以使用mongodump的--out选项指定转储数据的路径。
创建一个 运行 mongodump 的脚本并为您的路径指定不同的名称,即使用日期:
mongodump --out /data/dump/090516/
Shell 脚本示例:
#!/bin/sh
DIR=`date +%m%d%y`
DEST=$DIR
mkdir $DEST
mongodump --out=/data/dump/$DEST
来自 mongodocs:
覆盖文件
"Mongodump overwrites output files if they exist in the backup data folder. Before running the mongodump command multiple times, either ensure that you no longer need the files in the output folder (the default is the dump/ folder) or rename the folders or files."
大家好, 我想每天做一次备份,有时甚至一天做两次备份。转储文件名按实际日期命名。如果我每天备份两次,第一个备份会因名称相同而被覆盖。 如果文件已经存在,有什么方法可以告诉 mongodump 重命名(例如 5.9.2016(1))文件?
可以使用mongodump的--out选项指定转储数据的路径。
创建一个 运行 mongodump 的脚本并为您的路径指定不同的名称,即使用日期:
mongodump --out /data/dump/090516/
Shell 脚本示例:
#!/bin/sh
DIR=`date +%m%d%y`
DEST=$DIR
mkdir $DEST
mongodump --out=/data/dump/$DEST