Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time

gmadar / MongoDB-backup-to-Amazon-S3

this script is based on woxxy / MySQL-backup-to-Amazon-S3. Thanks woxxy!

This script is based on the s3cmd


  1. Register for Amazon AWS

  2. Install s3cmd (following commands are for debian/ubuntu, but you can find how-to for other Linux distributions on

     wget -O- -q | sudo apt-key add -
     sudo wget -O/etc/apt/sources.list.d/s3tools.list
     sudo apt-get update && sudo apt-get install s3cmd
  3. Get your key and secret key at this link

  4. Configure s3cmd to work with your account

     s3cmd --configure
  5. Make a bucket (must be an original name, s3cmd will tell you if it's already used)

     s3cmd mb s3://my-database-backups
  6. Put the file somewhere in your server, like /home/youruser

  7. run with sudo OR change the 'MONGODUMPPATH' to a folder with write permitions and give the script file 755 permissions chmod 755 /home/youruser/mongoToS3.shh or via FTP

  8. Edit the variables near the top of the file to match your bucket name

Now we're set. You can use it manually:

#set a new daily backup, and store the previous day as "previous_day"
sh /home/youruser/

#set a new weekly backup, and store previous week as "previous_week"
/home/youruser/ week

#set a new weekly backup, and store previous month as "previous_month"
/home/youruser/ month

But, we don't want to think about it until something breaks! So enter crontab -e and insert the following after editing the folders

# daily MySQL backup to S3 (not on first day of month or sundays)
0 3 2-31 * 1-6 sh /home/youruser/ day
# weekly MySQL backup to S3 (on sundays, but not the first day of the month)
0 3 2-31 * 0 sh /home/youruser/ week
# monthly MySQL backup to S3
0 3 1 * * sh /home/youruser/ month

Or, if you'd prefer to have the script determine the current date and day of the week, insert the following after editing the folders

# automatic daily / weekly / monthly backup to S3.
0 3 * * * sh /home/youruser/ auto

And you're set.


None yet.


creates a MongoDB dump and uploads it to Amazon S3 with Daily + Weekly + Monthly backups




No releases published


You can’t perform that action at this time.