1

From a bash backup script I want to call db.fsyncLock(), then execute other commands (fs snapshotting) and later db.fsyncUnlock() non-consecutively over the same connection, since it is advised as best practice.

I tried named pipes, but mongo shell crashes when having something piped via stdin. How can I achieve this?

neurolabs
  • 542
  • 3
  • 8
  • Surely you are just calling with the `--eval` option. Why would you need to keep the shell connection open? – Neil Lunn Mar 10 '15 at 10:03
  • because I need to execute other commands (filesystem snapshotting, lvm) in between the two mongo commands. I can't do that from the mongo shell AFAIK, but I should keep the connection open according to the docs (see linked documentation in my question). `--eval` definitely does not cut it. – neurolabs Mar 10 '15 at 16:02

1 Answers1

1

Was looking for a solution to the same problem and found this short article http://www.kamsky.org/stupid-tricks-with-mongodb/backups-and-locking that offer a solution using a script to run inside mongo that during the lock launch a bash command that perform the backup.

  • 1
    _Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline._ – Bugs Jan 11 '17 at 11:55