0

I have backed up the data from my deployed database successfully using the following commands:

mongodump admin -u user -p password

Is there a shell script to do this automatically with the password hidden(to protect the password even someone get the script)?

Justlike
  • 1,476
  • 10
  • 18

2 Answers2

0

You can use crontab to create scheduled task on the server that will run this command for you. in that way only those who have access to the server can get your password.

Here is a link how to do it https://sheharyar.me/blog/regular-mongo-backups-using-cron/

Ariel Henryson
  • 1,316
  • 1
  • 10
  • 13
0

You should implement the solution by Ariel with a read-only user. This limits the damage when someone still manages to obtain the script. It would also be good practice to store the password encrypted and let the scrip that runs the backup decrypt it.

Alex
  • 21,273
  • 10
  • 61
  • 73