HI Team,
Unable to track mongdump log. We need to know whether mongodump is completed or not in onpremises. how to log the mongodump activity. Please advise.
HI Team,
Unable to track mongdump log. We need to know whether mongodump is completed or not in onpremises. how to log the mongodump activity. Please advise.
mongodump --verbose
Hi Suresh,
Thanks for the reply.
Currently i am using cronjob for running backup in onprem. I need log for this activity. after finishing the mongodump backup. I am unable see whether the backup complted or not. Need logging to log file. Is it possible?
I don’t know how to do it but This may help you, This is from chatGPT .
Yes, it’s possible to log the output of the mongodump
command to a log file when running it as a cron job. This allows you to keep track of whether the backup was completed successfully and review any error messages if there are issues during the backup process.
To log the output of a command to a file, you can use the >>
operator to append the command’s output to a log file. Here’s how you can modify your cron job to log the mongodump
output:
Open your crontab for editing by running the following command:
crontab -e
Add your mongodump
command to the crontab file, and redirect both standard output (stdout
) and standard error (stderr
) to a log file using the >>
operator. For example:
0 2 * * * mongodump --uri "mongodb://username:password@hostname:port/database" >> /path/to/backup.log 2>&1
In this example:
0 2 * * *
schedules the mongodump
command to run daily at 2:00 AM. You can adjust the schedule as needed.
mongodump --uri "mongodb://username:password@hostname:port/database"
is your mongodump
command.
>> /path/to/backup.log
appends both stdout
and stderr
to the specified log file (/path/to/backup.log
). You should replace this with the actual path where you want to store the log file.
2>&1
redirects stderr
(file descriptor 2) to stdout
(file descriptor 1) so that both standard output and standard error are logged to the same file.
Save the crontab file and exit the text editor.
With this configuration, the output and any error messages generated by the mongodump
command will be appended to the specified log file. You can check this log file to monitor the backup process and review any potential issues.
Make sure the directory where you want to store the log file is writable by the user running the cron job to avoid permission issues.
Hi @Kiran_Joshy,
Yes, you need only to redirect the output in a file.
Regards
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.