I am using PythonAnywhere to host my web application. Using Mongodb as my database. Now my task is to take backup periodically and restore specific version of mongodb whenever I want.
To do it on local(windows machine), it is pretty easy. Install Mongodb utilities and execute command
mongodump --mongodbConnectionString //From location where this executable is stored
mongorestore --mongodbConnectionString
Now my challenge is to do it from PythonAnywhere. Here how should I use these utilities?
I have Linux executables for mongodb from mongodb site, I extracted bin folder from it, it look like below
Now I moved this bin folder to PythonAnywhere and tried to execute mongodump
command
~/../applications/mongodb-linux-x86_64-ubuntu1404-3.4.0/bin$ ./mongodump mongodbConnectionString
it failed with below error
bash: ./mongodump: Permission denied
My question is how to do mongodump and mongorestore from PythonAnywhere? My final goal is to do periodic backup of mongodb database
You need to setup correctly MongoDB binaries inside PythonAnywhere.
Normally, execution fails due wrong permissions.
Make sure:
- You have execution permissions (chmod u+x file)
- Binnaries have proper owner (chown user file)
- Binnaries have proper group (chgrp group file)
Note: You need to be sudoer
to grant such permissions