micahwedemeyer / automongobackup Goto Github PK
View Code? Open in Web Editor NEWNightly, rotated backups of MongoDB (port of AutoMySQLBackup for use with Mongo)
Nightly, rotated backups of MongoDB (port of AutoMySQLBackup for use with Mongo)
mongodump
executable may be missing and in order to improve the UX the script should attempt to install it using this logic
dnf
is present, try dnf install -y mongo-tools
yum
is present, try yum install -y mongo-tools
apt-get
is present, try apt-get install -y ???
Implementing this would avoid some confusions like the ones from #18
Sorry but i tried to run this script and its giving this error
automongobackup.sh: 368: [: yes: unexpected operator
automongobackup.sh: 393: [: yes: unexpected operator
MongoDB version v2.6.10
ubuntu 16.04 LTS
+(automongobackup:454): select_secondary_member(): local __return=secondary
+(automongobackup:458): select_secondary_member(): members=($(mongo --quiet --host $DBHOST:$DBPORT --eval 'rs.conf().members.forEach(function(x){ print(x.host) })' $OPTSEC ))
++(automongobackup:458): select_secondary_member(): mongo --quiet --host 127.0.0.1:27017 --eval 'rs.conf().members.forEach(function(x){ print(x.host) })'
^C
root@mondogb:/var/backups/mongodb# mongo --quiet --host 127.0.0.1:27017 --eval 'rs.conf().members.forEach(function(x){ print(x.host) })'
2016-09-06T21:44:29.413+0200 TypeError: Cannot read property 'members' of null
root@mongodb:/var/backups/mongodb#
I havent any inforamtion about this error in logs.
I'm getting this error.
Failed: error getting database names: not authorized on admin to execute command { listDatabases: 1 }
Tried using users with "backup" role and "root" role. Logging in through the shell and doing "show dbs" works fine. Mongodb 3.2.
Hi.
If you try to backup a replica set with authentication enabled and set primary as DBHOST, when the script executes line
members=( $(mongo --quiet --host $DBHOST:$DBPORT --eval 'rs.conf().members.forEach(function(x){ print(x.host) })') )
and line
is_secondary=$(mongo --quiet --host $member --eval 'rs.isMaster().secondary')
to discover a secondary, an authorization exception is raised. So, always the primary is chosen for the backup.
I resolved setting a new AUTH variable and putting it as parameter on previous commands. It works for me if, other than backup role, I assign clusterManager role to the user used to execute the dump. Compare the two files inside the zip attached to this issue to see my workaround.
By
Roberto
I just run ./automongobackup.sh
then I got ERROR: mongodump failed to create dumpfile: /var/backups/mongodb/daily/2014-06-05_10h32m.Thursday
I don't know why failed, I have installed mongo and by root
user.
Thanks for your time!
I keep getting that message.
I'm not a linux expert, not sure what to check
It seems this is already fixed in mongodump, but not updated in script. Please check.
I download the file and run it by ./automongobackup.sh . I already set mongo's path and mongodump can be use in shell. Why the script says command not found?? I using suse 10, root user, automongobackup.sh has x mod.
problem solved, user issue
I am having this error when running the script.
./automongobackup.sh: line 332: /var/backups/mongodb/127.0.0.1-2102.log: Permission denied
If DBNAME option is used, OPLOG param should be ignored since mongodb doesn't allow oplog unless it is a full dump and throws error
Error is not displayed while executing since it is running with --quiet option
OPLOG param should be ignored if DBNAME param present
Hello! Currently we can run a command when the backup finishes with the POSTBACKUP
option. I'm wondering whether there's a way to run a command specifically when the backup fails, or if there's some way to detect if it failed from within the POSTBACKUP
option?
My use case is: I have no idea how to set up mail
on my server, and would like to use a simple nodejs script like this:
require('nodemailer').createTransport('smtps://blablablabh.com%40gmail.com:[email protected]').sendMail({to:'[email protected]', from:'automongobackup', subject:'automongobackup ERROR - check your logs!'});
I'm a bash noob, so if this is not something that's achievable, that's cool - I'll try wrangle together some workaround. Thanks!
When this is a single 'master' server that is not in a replicaset and the config is set to:
# Choose other Server if is Replica-Set Master
REPLICAONSLAVE="yes"
The following errors are generated:
exception: connect failed
exception: connect failed
exception: connect failed
exception: connect failed
exception: HostAndPort: bad port #
exception: connect failed
exception: connect failed
exception: connect failed
exception: connect failed
exception: connect failed
exception: connect failed
Please see my answer on ServerFault from 'Adam Knowles' at
Hi, I love this script, and I'm using aws s3 --sync
to upload $BACKUPDIR
to s3, via the $POSTBACKUP
hook. However, since the end of the script calls
rm -f "$LOGFILE" "$LOGERR"
The upload operation will fail partially through. This was surprisingly hard to debug (I thought files were missing due to cleanup or rotation). Anyway, having an option to disable the logfile purge, or wait until $POSTBACKUP
finishes could be useful. (Which might be trick with aws s3
's async behavior.)
In anycase, there might be someone else who finds this issue useful in the course of debugging. 🍏
always results in ERROR: too many positional options
because DBPASSWORD get expand then OPT get expand again, thing get tricky to debug.
i use this script in a rails application , but at this time the application is getting multitenant and i have to create folders for each tenant , i will trigger the script with a rake task with whenever gem ...
What is the query of mongodb that will take the datas in each model (with a tenant_id) and store it in a folder with the name or id of tenant ... at this time there is no need to store tenant model. Just for the models data belongs to tenants.
--quiet should be removed from mongodump. its not available in the actually version.
[root@vsm-prod backuptest]# mongodump --version
mongodump version 2.2.0
Hello,
i set MAILCONTENT to quiet, but get emailed by cron anyway. when i look into the code, i just see some if queries regarding MAILCONTENT=log but nothing about stdout,files or quiet. Do i miss that part?
OS: Ubuntu 16.04
Mongo version 3.4
ISSUE:
Started running the bash script providing the hostname, port, user, password and auth database but it just creates an empty log file, empty folders in the location.
But it does not start any backup or doesn't write any logs can anyone please help me here.
NOT AN ISSUE but can't find where to delete this ticket, no delete button here!!! unbelievable..
I try to use this script to backup a specific database on mongohq with no sucess
I have set a user on the database i want to backup and it's running mongo 2.4.4.
I set up DBAUTHDB and then find that the problem was with option --authenticationDatabase, which just didn´t work as expected.
It however works fine if i replace --authenticationDatabase with --db
I don´t know if this is a issue with the script or with my configurations, since i don't see no reason why --authenticationDatabase doesn´t work for my case.
i edited the script to fit this problem, adding new field DBNAME and pass --db if field is set otherwise use --authenticationDatabase if DBAUTHDB is set.
if open to pull request just say something.
Nice script by the way ;)
I have problems with the hourly Backups.
I enabled oplog on mongod 3.2 standalone with the --master param on Ubuntu 14.04.
All other rotations are working: daily, week, ... but for hourly backups the script create no file. Also no error message. Any ideas?
DOHOURLY="yes"
HOURLYRETENTION=24
DODAILY="yes"
DAILYRETENTION=0
DOWEEKLY="yes"
WEEKLYDAY=6
WEEKLYRETENTION=4
DOMONTHLY="yes"
MONTHLYRETENTION=4
I configured this script to just do daily and hourly backups on a single instance of mongod w/o auth. Pretty simple. My question is when I enable both daily / hourly to "yes", how do I schedule this in cron.daily or crontab? Would I need to schedule this script every hour and if so, does that mean it will take a full backup (daily) every single hour I really just want an hourly backup? Confused on how the logic flows here. How do I get dailys at 1 AM and an hourly backup every hour? Are they just full hourly dumps?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.