In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Linux system how to mongo database regular backup, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Using the method, use the command nohup python-u mongod_back.py > out.log 2 > & 1 & hang in the script and perform a mongodb data backup at 0 o'clock every day.
Python script import time import schedule import os def auto_backup_mongo (): commands = "cd / home/webapp/backup/mongo_bak & & pwd &. / mongod_bak.sh"os.system (commands) schedule.every () .day.at (" 23:59 ") .do (auto_backup_mongo) while True: schedule.run_pending () time.sleep (1) shell Script #! / bin/sh DUMP=/home/webapp/Downloads/mongoDB/mongodbserver/bin/mongodump # mongodump backup file execution path OUT_DIR=/home/webapp/backup/mongo_bak/mongod_bak_now # temporary backup directory TAR_DIR=/home/webapp/backup/mongo_bak/mongod_bak_list # backup storage path DATE= `date +% Yyears% masks% dashes% hacks% Manners% S` # get the number of DB_USER=XXXX# of the current system time According to the database account DB_PASS=XXXX # database password DB_NAME=TEST # database name IP=xx.xx.xx.xx:27017 DAYS=365 # DAYS=30 represents the backup 30 days before deletion That is, only the last 30 days backup TAR_BAK= "mongod_bak_$DATE.tar.gz" # final saved database backup file name cd $OUT_DIR rm-rf $OUT_DIR/* mkdir-p $OUT_DIR/$DATE $DUMP-h $IP-u $DB_USER-p $DB_PASS-d $DB_NAME-o $OUT_DIR/$DATE # backup database tar-zcvf $TAR_DIR/$TAR_BAK $OUT_DIR/$DATE # compressed to .tar.gz format find $TAR_ DIR/-mtime + $DAYS-delete # deleting the backup exit # from 30 days ago will it help you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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
© 2024 shulou.com SLNews company. All rights reserved.