In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
#! / bin/bash
# backup MongoDB
# mongodump command path
DUMP=/usr/local/mongodb/bin/mongodump
# temporary backup directory
OUT_DIR=/data/mongodb_bak/mongodb_bak_now
# backup storage path
TAR_DIR=/data/mongodb_bak/mongodb_baklist
# get the current system time
DATE= `date +% Y%m_%d#mongo hostname HOST=ifconfig ens192 | grep netmask | awk'{print $2}'`
# backup database
DB=data01
# Database account
DB_USER=root
# Database password
DB_PASS=123456
# DAYS=15 means to delete backups from 15 days ago, that is, to keep only backups for nearly 15 days.
DAYS=15
# the final saved database backup file
TAR_BAK= "mongodbbak$DATE.tar.gz"
# determine whether the backup command file and backup directory exist
If [!-f "$DUMP"]; then
Echo "mongodump the command does not exist, check the correct path."
Exit 0
Elif [!-d "$OUT_DIR"]; then
Echo "Create tmp backup dir"
Mkdir-p $OUT_DIR
Elif [!-d "$TAR_DIR"]; then
Echo "Create Backup dir"
Mkdir-p $TAR_DIR
Els
Echo "Start Backup"
Fi
Cd $OUT_DIR
Rm-rf $OUT_DIR/*
Mkdir-p $OUT_DIR/$DATE
# back up a single database
$DUMP-h $HOST-u $DB_USER-p $DB_PASS-d $DB-o $OUT_DIR/$DATE
# backup all databases
# $DUMP-h $HOST-u $DB_USER-p $DB_PASS-- authenticationDatabase "admin"-o $OUT_DIR/$DATE
# compressed to .tar.gz format
Tar-zcvf $TAR_DIR/$TAR_BAK $OUT_DIR/$DATE
# Delete backup files from 15 days ago
Find $TAR_DIR/-mtime + $DAYS-delete
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
On the basis of what I just did. Insert into look values (2); insert into look values (3)
© 2024 shulou.com SLNews company. All rights reserved.