Joyent QuickBackup for Percona MySQL server

Modified: 27 Jul 2015 22:17 UTC
Stability: Unknown

Part of the Joyent Percona Instance is Joyent QuickBackup, a fast non-blocking MySQL backup service powered by Percona Xtrabackup on the back end. This service is pre-configured with the username and password but disabled by default. The only settings you need to configure are the minute, hour, day, and expiredays.

Configuring Joyent Quickbackup

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 MySQL user for QuickBackup 16 characters qb-xxxxxxxx
quickbackup/password MySQL 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 /backups
quickbackup/stream Streaming method for Quickbackup to use xbstream or tar xbstream

To see how properties are set for the service, use the svcprop command. For example:

# svcprop svc:/pkgsrc/quickbackup-percona | grep "quickbackup/"
quickbackup/backupdir astring /var/backups/percona
quickbackup/databases astring all
quickbackup/day astring all
quickbackup/expiredays astring 3
quickbackup/stream astring xbstream
quickbackup/username astring qb-xxxxxxxx
quickbackup/password astring xxxxxxxx
quickbackup/hour astring 0
quickbackup/minute astring 0

# svcprop svc:/network/mysql-quickbackup | grep "quickbackup/"
quickbackup/day astring all
quickbackup/expiredays astring 3
quickbackup/hour astring 0
quickbackup/minute astring 0
quickbackup/username astring qb-xxxxxxxx
quickbackup/password astring xxxxxxxx
quickbackup/backupdir astring /backups
quickbackup/stream astring xbstream

To change a service property use the svccfg command. You specify which property you want to change and the value you want to set. For example, this command is setting the property value for the quickbackup/backupdir property:

13.1.0 and later

# svccfg -s pkgsrc/quickbackup-percona setprop quickbackup/backupdir = /newdirectory

1.6.0 and earlier

# svccfg -s network/mysql-quickbackup setprop quickbackup/backupdir = /newdirectory

When making a change to a Quickbackup property, you need to restart the service for the change to take effect:

13.1.0 and later

# svcadm disable quickbackup-percona
# svcadm enable quickbackup-percona

1.6.0 and earlier

# svcadm disable mysql-quickbackup
# svcadm enable mysql-quickbackup

You can then verify that your change was set correctly with svcprop.

Backup Files and Log Files

The location of the backup and log files is different depending on which image version you are running.

  13.1.0 and later 1.6.0 and earlier
backups /var/backups/percona /backups
logs /var/log/mysql/quickbackup-percona.log /var/log/mysql/quickbackup.log

Backing up Automatically

By default, the service is set to back up every night at midnight. To set the service to perform a backup every 15 minutes of every hour Monday, Tuesday, Wednesday, Thursday, and Friday, you would use the following svccfg commands:

13.1.0 and later

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

1.6.0 and earlier

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

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

13.1.0 and later

# svcadm refresh quickbackup-percona
# svcadm enable quickbackup-percona
# svcs quickbackup-percona
STATE          STIME    FMRI
online         Apr_29   svc:/pkgsrc/quickbackup-percona:default

1.6.0 and earlier

# svcadm refresh mysql-quickbackup
# svcadm enable mysql-quickbackup
# svcs mysql-quickbackup
STATE          STIME    FMRI
enabled        Apr_13   svc:/network/mysql-quickbackup

If the backup completed successfully you will see a confirmation message in the log like the following:

Backup completed successfully.

At the end of every backup, QuickBackup cleans up the old backup files and removes them if they are older than the value set for quickbackup/expiredays. It does this by checking the last modification time of the backup file.

Backups are stored in files named %Y-%m-%d_%H-%M-%S-backup.tar.gz. The backup files contain all of the databases by default or each database you specified in the quickbackup/databases setting.

See Backup Files and Log Files for the location of the log file.

Backing up Manually

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

13.1.0 and later

# quickbackup-percona backup
* Backup for /var/backups/percona/2013-05-01_18-38-44-backup.xbs
* Backup completed successfully
* Rotation completed successfully

1.6.0 and earlier

# quickbackup backup
* Backup for /backups/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 From a Backup

To restore a backup:

Shut down the MySQL server:

13.3.0 and later

# svcadm disable svc:/pkgsrc/percona
# svcs svc:/pkgsrc/percona
STATE          STIME    FMRI
disabled       21:11:46 svc:/pkgsrc/percona:default

13.1.0

# svcadm disable percona-server
# svcs percona-server
STATE          STIME    FMRI
disabled       14:19:21 svc:/pkgsrc/percona-server:default

1.6.0 and earlier

# svcadm disable mysql:percona
# svcs mysql:percona
STATE          STIME    FMRI
disabled       14:19:21 svc:/network/mysql:percona

Indicate which backup you want to restore by passing in the path to the backup file:

13.1.0 and later

# quickbackup-percona restore /var/backups/percona/2011-04-16_20-20-00-backup.tar.gz
Restore from /var/backups/percona/2011-04-16_20-20-00-backup.tar.gz
Restore completed successfully.

1.6.0 and earlier

# quickbackup restore /backups/2011-04-16_20-20-00-backup.tar.gz
Restore from /backups/2011-04-16_20-20-00-backup.tar.gz
Restore completed successfully.

If successful, you will see a confirmation message that the restore completed successfully.

If there is an error, you will need to check the QuickBackup log file. See Backup Files and Log Files for the location of the log file.

Once the restore is complete, re-enable MySQL:

13.3.0 and later

# svcadm enable percona-server
# svcs percona-server
STATE          STIME    FMRI
online         Apr_29   svc:/pkgsrc/percona-server:default

13.1.0

# svcadm enable percona-server
# svcs percona-server
STATE          STIME    FMRI
online         Apr_29   svc:/pkgsrc/percona-server:default

1.6.0 and earlier

# svcadm enable mysql:percona
# svcs mysql:percona
STATE          STIME    FMRI
online         14:30:31 svc:/network/mysql:percona

At this point, everything is running from the restored backup.

Choosing a Streaming Method (optional)

In Quickbackup version 3.0 (and later), you can select between two different streaming methods for performing a backup: tar and xbstream.

The default is now xbstream, but you can use either.

You can configure the streaming method by setting the value of the quickbackup/stream property. To change it:

13.1.0 and later

# svccfg -s pkgsrc/quickbackup-percona setprop quickbackup/stream = tar
# svcadm refresh pkgsrc/quickbackup-percona

1.6.0 and earlier

# svccfg -s network/mysql-quickbackup setprop quickbackup/stream = tar
# svcadm refresh network/mysql-quickbackup
When doing a Quickbackup restore, you now need to specify the streaming method used for the backup from which you are trying to restore.

Below is a comparison of the time it takes to perform a backup between 'tar' and 'xbstream' on a 10 GB dataset.

tar: Time to back up 10 GB

# time quickbackup backup
Backup for /backups/2012-06-11_17-25-49-backup.tar.gz
Backup completed successfully
Backup rotation completed

real    6m30.905s
user    4m29.651s
sys     0m36.489s

xbstream: Time to back up 10 GB

# time quickbackup backup
Backup for /backups/2012-06-11_17-23-41-backup.xbs
Backup completed successfully
Backup rotation completed

real    0m50.938s
user    0m48.366s
sys     0m21.550s