Entries tagged as snapshots
Sunday, February 23. 2014
I'm happy to announce the release of mylvmbackup version 0.15. It is now available for download from http://lenzg.net/mylvmbackup/ and https://launchpad.net/mylvmbackup
Probably the biggest highlight of 0.15 is the addition of zbackup as an additional backup type. I'd like to thank Ivan Korjavin for contributing this new feature.
Additionally, this release provides several improvements and bug fixes. For example, it's now possible to back up more than a single my.cnf configuration file by providing a directory name like /etc/mysql instead.
Please see the ChangeLog and bzr history for more details.
Monday, June 24. 2013
It's my great pleasure to announce the release of mylvmbackup version 0.14.
This release includes a large number of improvements, code cleanups, and new functionality.
I would like to thank Ask Bjørn Hansen, Ben Bonnel, Norbert Tretkowski, Neil Wilson, Klaus Ethgen and Alexandre Anriot for their feedback and contributions to this release.
The release is available as a source tarball and generic RPM package. Packages for other distributions are available from the openSUSE Build Service.
Some notable highlights from the ChangeLog (please check the bzr commit log for a more detailed history of changes):
- Improved error handling: send out an email if mail_report_on has been set to "errors" and a log message with log level LOG_ERR was logged.
- Abort and clean up if the snapshot volume could not be mounted
- Abort and clean up if the backup creation failed
- Exit with a non-zero return code if errorstate was set
- Enabled timestr() formatting sequences for snapshot volume names, to create snapshot names which contain a dynamic date value. This can be useful when thin provisioned snapshots are used as the actual backup by enabling the keep_snapshot option
- Added "thin" option to mylvmbackup.conf (default=0), to enable thin provisioned LVM snapshots
- Added new configuration option "recoveryopts" that allows to modify the command line options that are passed to the MySQL instance that performs the InnoDB recovery (BUG#544295 and BUG#1091950). The current default options are "--skip-networking --skip-grant --bootstrap --skip-syslog --skip-slave-start" (which better accommodates MySQL 5.1)
- Merged patches from Alexandre Anriot to provide a mail reporting method which sends the log output via email and a new "purge" action that allows to only keep a defined number of backups in the backup directory
- Applied patch contributed by Klaus Ethgen that removes the annoying LVM warnings about a leaked file descriptor (DBD:mysql does not add FD_CLOEXEC on the MySQL socket)
- BUG#1086313: mvlvmbackup lacks support for 'thin' LVM snapshots (Thanks to Neil Wilson for the patch)
- BUG#787063: Ensure to clean up temporary .pos files when the snapshot mount is kept, too
- Applied small patch from Norbert Tretkowski: change umask to 077 before creating the tarball backup files to prevent them from being readable by everyone
- BUG#593220: Fixed the compressarg option for cat (removed the comment)
- Applied patch contributed by Ben Bonnel to add a new configuration option "rsnaprsyncarg" that allows one to pass special options to the rsync process when using the rsnap backend.
- Applied patch provided by Ask Bjørn Hansen to allow targets not to have a timestamp (e.g. for rsync targets)
Wednesday, August 11. 2010
I tend to switch between Linux and OpenSolaris as my desktop operating system from time to time. To be more flexible in this setup, I store most of my work-related data (e.g. source trees, VirtualBox images) on an external 320GB USB disk drive, using the ZFS file system. While OpenSolaris supports ZFS natively, I can access the file system on Linux using zfs-fuse and I could even mount these file systems on a FreeBSD system, if needed. There aren't that many file systems that allow an easy exchange of data between (Open)Solaris and Linux – the other ones that I am aware of are FAT and UFS, which both don't give me the confidence and flexibility I need.
A while ago, I purchased a second external drive of the same size and now use both of them in a mirrored configuration. This gives me several benefits:
- Redundancy: external disk drives have a higher risk of getting physically damaged, so having a mirrored copy of my data ensures that I won't lose anything important if one of the drives dies.
- Increased performance: ZFS is capable of distributing reads across both devices, thus I get twice the speed of a single USB 2.0 port, if I connect the drives to ports attached to separate USB host controllers.
- Automatic resyncing: When I'm on the road, I only take one half of the mirror with me. In case this drive gets lost/stolen, I still have a second copy of the data at home. ZFS complains about the pool being in degraded state, but continues to work normally. When I return home, I simply attach the second drive again and ZFS automatically resyncs (resilvers) anything that has been modified in the meanwhile.
- I can use snapshots for backup purposes. I have a small Intel Atom based PC (running OpenSolaris) that acts as my central file server (using two 1TB disks in a ZFS mirror) and CUPS print server. If I want to create a backup of my external USB disks, I create ZFS snapshots of the file systems in question and transfer these to the home server using "zfs send/receive". This works both locally by connecting the drives to the server box directly or via SSH over the network. I wrote a small shell script to automate this process. The transfer is done in an incremental fashion – only the differences between the current and the last snapshot are being propagated. To save disk space on the external drives, I usually discard all older snapshots except for the last one or two. On the file server, I maintain snapshots for a longer time period. The snapshots are named by using a simple date/time timestamp (filesystem@YYYY-MM-DD-HH:MM), this makes it easy to go back to a particular snapshot in case I'm looking for something I may have removed by accident, but I still recall when it was last used.
From my experience, ZFS is a very solid and reliable solution, providing impressive functionality with a very user-friendly UI (you only need use two commands, zfs and zpool).
If you want to learn more about ZFS and how to use it in practice, consider attending my upcoming talk (in German) about this subject at FrOSCon 2010 in Sankt Augustin, Germany!
Sunday, September 6. 2009
I am happy to announce that mylvmbackup version 0.13 has now been released. This release includes a fix for a nasty bug in on of the recently added Perl hooks (precleanup.pm) and some added functionality (better support for remote rsync backups).
From the ChangeLog:
- Deleted sample precleanup.pm hook as it has potential to cause harm and is too specialized on a particular use case (BUG#394668)
- Added support for rsync via SSH (BUG#392462)
- Fixed InnoDB recovery in case a relative path to the MySQL data directory is defined (BUG#38337), improved the documentation of relpath in the man page.
Saturday, June 20. 2009
After a long hiatus, I am happy to announce that mylvmbackup version 0.12 has now been released. This release includes a large number of improvements, minor code cleanups, as well as some new functionality. In particular, I would like to thank Matthew Boehm, Tim Stoop, Baron Schwartz, Ville Skyttä and Ronald Bradford for their contributions.
Some notable highlights from the ChangeLog:
- Removed the absolute path names to external tools (make sure $PATH is correct)
- Added --log-err to the startup options of the recovery instance to avoid cluttering the server's error log
- Added support for hooks written as Perl Modules. (Matthew Boehm)
- Added support for date/time-formatted path names for backupdir and mountdir (Matthew Boehm)
- Backupdir and mountdir are now created automatically (Matthew Boehm)
- Added new hook "logerr" when an error is logged. (Matthew Boehm)
- Added Option --keep-mount... (Tim Stoop)
- Removed the bind mount, now requires LVMv2
- Support reading login/password from ~/.my.cnf (Baron Schwartz)
- Documentation fixes and improvements (Ville Skyttä) (Bug #302144)
Thursday, February 26. 2009
Today I gave my first MySQL University session as a speaker, talking about Backing up MySQL using file system snapshots. The talk went quite well (at least that was my impression) and we had ~10 people attending. The slides (PDF) and a recording of the session are now available from the Wiki page. Unfortunately the recording lacks the audio track, which is a bit of a bummer. We've submitted a support request with the DimDim folks, so hopefully they can provide us with a complete recording.
There was one question during the session that I was not able to answer myself, so I'm asking for your insights here:
Consider we're using InnoDB and MyISAM tables on a file system that can be snapshotted (e.g. Linux LVM or ZFS) and we're performing the following operations:
- FLUSH TABLES WITH READ LOCK (yes, this won't help for the InnoDB tables)
- Create the snapshot
- Store the output of SHOW MASTER/SLAVE status in a file to be part of the backup
- UNLOCK TABLES
- Mount the snapshot
- Start a second MySQL instance that accesses the tables on the snapshot, let InnoDB perform its table recovery
- Shut down the second instance and perform the backup of the snapshot
The question that came up was if this actually still is a consistent backup, considering that InnoDB rolled back uncommited transactions. Does the state of the tables still match the binary log positions we noted before? I assume yes, as long as the transaction does not involve modifications non-transactional tables.
Another suggestion that came up was to change InnoDB's configuration variable innodb_max_dirty_pages_pct to "0" prior to performing the snapshot, to minimize the amount of dirty pages that have not been written to disk (and thus reducing the time required for recovering later). I wonder if this would make a difference...
What other InnoDB variables might have a noteworthy effect in the context of snapshot backups? I am looking forward to your comments.
Monday, December 1. 2008
Some days ago, I released version 0.11 of mylvmbackup a Perl script that performs consistent backups of a MySQL server by using LVM filesystem snapshots. The source archive as well as a generic RPM can be found on the project home page, packages for many Linux distributions are available on the openSUSE Build service.
This release includes some new functionality as well as numerous bug fixes and improvements, most notably:
- Added support for using rsnap as a backup backend (Matt Lohier)
- The documentation is now maintained in POD style instead of asciidoc (Matthew Boehm)
- Support using non-GNU tar and additional compression methods (e.g. bzip2, lzma) (Alexander Skwar)
- Code cleanups, improved error handling and logging
I would like to thank all the contributors for their support! More details about the changes in this release, directly from the ChangeLog:
- Added new option "--quiet" that suppresses informal logging output (warnings and errors will still be printed/logged)
- Applied patch from "kjetilho" that makes mylvmbackup more robust and paranoid when it comes to handling errors/failures (Bug #298175) Now the script aborts cleanly in case of any error.
- Fixed error handling in case of a failed DB connection (patch submitted by Matthew Boehm, Bug #280989)
- Merged changes from Alexander Skwar: Fix for Bug #278478 and implemented Blueprint "Improve the tar backup backend of mylvmbackup"
- Fixed Bug #271671: "overloading parameters does not work" by removing the default values for host and port from the configuration file and removing the unnecessary check for passing both host and socket at the same time. Updated documentation and configuration file comments accordingly.
- Applied patch suggested by "Jonas" to fix Bug #267944: "backup returns successfully when snapshot creation fails"
- Code cleanup: moved flushing of tables in a separate subroutine flush_tables()
- Code cleanup: moved log messages into the respective subroutines
- Code cleanup: use return values of subroutines instead of updating global variables
- Improved some log messages to explain what was DONE or FAILED
- Code cleanup: build up long command strings in a $command variable before passing it to system()
- Renamed subroutine create_snapshot() to create_lvm_snapshot()
- Merged patch from Matthew Boehm: Removed old asciidoc documentation in favor of POD style. This removes the dependency on the external program a2x for creating documentation and uses the 'built-in' pod2html and pod2man instead. Updated the Makefile to accommodate the change.
- Applied patch from Matthew Boehm to make the backup file name suffix configurable via a "--suffix" option. Updated the man page accordingly.
- Applied patch from Matt Lohier to support rsnap as a backup backend
- Moved the list of contributors from the man page into a separate CREDITS file, added missing names
Enjoy!
Friday, July 11. 2008
I am happy to announce that a new version (0.9) of mylvmbackup has been released. This is the first release since the source code has been moved from Subversion to Bazaar and is now hosted on Launchpad.net. I would like to thank Robin H. Johnson and Patrick Hahn for providing the patches that contributed to this new release!
mylvmbackup is a tool for quickly creating backups of MySQL server's data files. To perform a backup, mylvmbackup obtains a read lock on all tables and flushes all server caches to disk, makes an LVM snapshot of the volume containing the MySQL data directory, and unlocks the tables again. The snapshot process takes only a small amount of time. When it is done, the server can continue normal operations, while the actual file backup proceeds.
From the ChangeLog:
- Applied patch from Patrick Hahn: provide an option to call external scripts/applications (hooks) at various stages of the backup process. See the man page for instructions
- Added options "--skip_hooks" to disable the execution of hooks and "--hooksdir" to define the location for these (default is /usr/share/mylvmbackup)
- Updated documentation: added new options and instructions on how to use hooks
- Applied patch from Robin H. Johnson: Full support for an rsync:// service as the backup destination. If you include any path fragments with the rsync module name, they must already exist!
- Updated documentation to reflect these changes
- Updated TODO
You can download a source tarball or RPM from the project home page. Additional packages for various Linux distributions can be obtained from the openSUSE Build Service. Packages for Gentoo and Debian should appear shortly, too.
Enjoy! Please let me know how mylvmbackup works for you, either by posting to our mailing list or by submitting a bug report. Thanks!
Wednesday, April 16. 2008
While reading Colin's post about LugRadio Live, I stumbled over the Zumastor Linux Storage Project. Going through the project home page and their HOWTO got me curious - could this eventually become an alternative to using DRBD (for replicating data) and LVM snapshots (for performing backups)?
Zumastor is Free software that adds enterprise storage features (primarily improved snapshots and remote replication) to Linux.
Snapshots
LVM already lets administrators create snapshots, but its design has the surprising property that every block you change on the original volume consumes one block for each snapshot. The resulting speed and space penalty usually makes the use of more than one or two snapshots at a time impractical.
Zumastor keeps all snapshots for a particular volume in a common snapshot store, and shares blocks the way one would expect. Thus making a change to one block of a file in the original volume only uses one block in the snapshot store no matter how many snapshots you have.
Replication
Andrew Tridgell's rsync is a wonderful tool for replicating files remotely. However, when doing periodic replication of large numbers of infrequently changing files, the overhead for figuring out what files need to be sent can be extreme.
Zumastor keeps track of which block change between one snapshot and the next, and can easily send just the changed blocks. Thus Zumastor can do frequent replication of large filesystems much more efficiently than rsync can.
I assume it's not ready for production use yet, but it would sure be interesting to investigate on how to utilize it for the purpose of running MySQL on top of it...
I will keep an eye on this project, I wonder if I will have to add support for Zumastor snapshots to mylvmbackup at some point? 
Friday, April 11. 2008
I am happy to announce the release of mylvmbackup version 0.8. mylvmbackup is a tool for quickly creating backups of a MySQL server's data files. To perform a backup, mylvmbackup obtains a read lock on all tables and flushes all server caches to disk, makes an LVM snapshot of the volume containing the MySQL data directory, and unlocks the tables again. The snapshot process takes only a small amount of time. When it is done, the server can continue normal operations, while the actual file backup proceeds.
Below is the list of changes since version 0.6. You may wonder what happened to version 0.7 - it had a rather short life cycle as I was informed about a bug that I fixed quickly before I made a wider release announcement of 0.7.
- Fixed a bug in the InnoDB recovery function: the second mysqld process clobbered the socket file of the primary MySQL instance (thanks to Alain Hoang for reporting this)
- Updated the man page, noted some other limitations of the InnoDB recovery function
- Bug fix: use the correct mysqld parameter to provide an alternative PID file (--pid-file instead of --pidfile) - thanks to Guillaume Boddaert and Jim Wilson for reporting this!
- Added option "--skip_mycnf" to skip including a copy of the MySQL configuration file in the backup, added a safety check that the file actually exists prior to backing it up.
Updated package are available from the home page and via the openSUSE Build Service as usual. Updated packages for Debian/Ubuntu and Gentoo Linux should also be available shortly. Enjoy!
Speaking of LVM snapshot backups: I will be giving a talk about this subject at our MySQL Conference 2008 in Santa Clara, CA next week. If you are curious about how MySQL can be backed up using this technology, please consider to stop by!
Saturday, January 19. 2008
While browsing the many blog entries on blogs.sun.com about the MySQL Acquisition (thanks a lot for the very warm welcome!), I stumbled over this (Python-based) utility: SnapBack, a tool that uses ZFS snapshots to perform physical backups of MySQL databases on Solaris. Very cool! This is actually something I was wanting to add to the mylvmbackup script, too - I have to take a closer look at how this is done (I tried to install OpenSolaris on a VirtualBox instance, but it caused it to crash the emulator).
|