mongodb-backup-restore-ubuntu
v0.0.1
Published
mongodb backup restore ubuntu
Downloads
5
Readme
#MongoDB Backup Restore
#Server #SV1 => Client #Local => Server #SV2
#SV1
ssh root@ipv4_sv1
# bachup ... --db=mydb1
# bachup ... --db=mydb2
mongodump --host=127.0.0.1 --port=27017 --username=admin --authenticationDatabase=admin --out=/root/backup_mongodump --db=
# Enter password:
# compress folder backup_mongodump
tar -czvf backup_mongodump.tar.gz backup_mongodump
# create server to download
python3 -m http.server 4567
## --------------------------------------------- ##
#Server #SV1 => Client #Local => Server #SV2
## --------------------------------------------- ##
#Local download this url
# http://ipv4_sv1:4567/backup_mongodump.tar.gz
#SV1
# remove folder and file
rm -rf backup_mongodump backup_mongodump.tar.gz
#Local
cd ~/Downloads
tar xvf backup_mongodump.tar.gz
# restore database to #SV2
mongorestore --host=ipv4_sv2 --port=27017 --username=admin --authenticationDatabase=admin ~/Downloads/backup_mongodump
# remove folder and file
rm -rf backup_mongodump backup_mongodump.tar.gz
## --------------------------------------------- ##
# OR Server #SV1 => Server #SV2
## --------------------------------------------- ##
ssh root@ipv4_sv2
wget http://ipv4_sv1:4567/backup_mongodump.tar.gz
#SV1
# remove folder and file
rm -rf backup_mongodump backup_mongodump.tar.gz
#SV2
tar xvf backup_mongodump.tar.gz
# restore database to #SV2
mongorestore --host=127.0.0.1 --port=27017 --username=admin --authenticationDatabase=admin ~/backup_mongodump
# remove folder and file
rm -rf backup_mongodump backup_mongodump.tar.gz