Joyent Quickbackup for MongoDB

Modified: 11 Mar 2015 14:46 UTC

Part of the Joyent MongoDB Instance is Joyent QuickBackup, a fast MongoDB backup service powered by mongodump on the back end. This service is pre-configured with the username and password but is disabled by default. The only things you need to configure are the minutehourday, and expiredays.

In this topic:

Backing up MongoDB with Joyent QuickBackup (schedule)

To configure the backup service, use the svccfg command to set the following values. By default, the service is set to backup every night at midnight.

Property Description Accepted Values Default Value
quickbackup/username MongoDB user for QuickBackup 16 characters qb-xxxxxxxx
quickbackup/password MongoDB password for QuickBackup 41 characters xxxxxxxxxxx
quickbackup/minute Minute of the hour to backup 0-60 comma separated or 'all' 0
quickbackup/hour Hour of the day to backup 0-23 comma separated or 'all' 0
quickbackup/day Day of the week to backup sun-sat comma separated or 'all' all
quickbackup/expiredays Number of days to keep backups 1-255 or 'none' 3
quickbackup/databases Name of databases to backup dbname1,dbname2 or 'all' all
quickbackup/backupdir Name of directory to backup to /directory /var/backups/mongodb

To see the current settings, use the svcprop command like this:

# svcprop quickbackup-mongodb | grep "quickbackup/"
quickbackup/backupdir astring /var/backups/mongodb
quickbackup/databases astring all
quickbackup/day astring all
quickbackup/expiredays astring 3
quickbackup/hour astring 0
quickbackup/minute astring 0
quickbackup/username astring qb-xxxxxxxxxxx
quickbackup/password astring xxxxxxxxxxxxxxxx

For example, to perform a backup every 15 minutes of every hour Monday through Friday, you would use the following svccfg commands:

# svccfg -s pkgsrc/quickbackup-mongodb setprop quickbackup/minute = 0,15,30,45
# svccfg -s pkgsrc/quickbackup-mongodb setprop quickbackup/hour = all
# svccfg -s pkgsrc/quickbackup-mongodb setprop quickbackup/day = mon,tue,wed,thur,fri

After setting the properties use the svcadm command to refresh and restart the service:

# svcadm refresh pkgsrc/quickbackup-mongodb
# svcadm enable pkgsrc/quickbackup-mongodb
# svcs pkgsrc/quickbackup-mongodb
STATE          STIME    FMRI
enabled        21:11:00 svc:/pkgsrc/quickbackup-mongodb:default

Each backup is contained as a single file in the /var/backups/mongodb directory. The filename format is %Y-%m-%d_%H-%M-%S-backup.tar.gz. The backup files contain all of the databases by default or each database you specify in the quickbackup/databases property.

QuickBackup logs all status messages for backups to /var/log/mongodb/quickbackup-mongodb.log. If a backup complets successfully, you will see a confirmation message at the end of the log file.

Backup completed successfully.

At the end of every backup QuickBackup will do a clean up of old backup files and remove them if the age of the files exceeds the value set for quickbackup/expiredays. It does this by checking the last modification time of the backup file.

Backing up MongoDB with Joyent QuickBackup (manually)

To make a backup manually (not on a schedule) with QuickBackup you can call the script by its self.

# quickbackup-mongodb backup
* Backup for /var/backups/mongodb/2012-10-12_19-57-41-backup.tar.gz
* Backup completed successfully
* Rotation completed successfully

After the backup it will rotate the backup files to quickbackup/expiredays set.

Restoring a MongoDB backup with Joyent QuickBackup

To restore a backup, the MongoDB service must be running. You can check this by running the following SMF command:

# svcs pkgsrc/quickbackup-mongodb
STATE          STIME    FMRI
enabled        21:11:00 svc:/pkgsrc/quickbackup-mongodb:default

You then need to specify the path to the backups you want to restore in the following way:

# quickbackup-mongodb restore /var/backups/mongodb/2012-03-20_20-59-48-backup.tar.gz
* Restore from /var/backups/mongodb/2012-03-20_20-59-48-backup.tar.gz
* Restore completed successfully

If successful, you will see a confirmation message that the restore completed successfully. If you receive an error, check the QuickBackup restore log file at /var/log/mongodb/quickbackup-mongodb.log.