Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What is the nature of the backup? Is it a completely replica? Archive? ... etc.
You could write a script using something like tree() or: find . -depth; or: ls -aR; on both directories and check for whether there is a difference and if you find one then return the backup command...
Or You could write a script using diff() andor cmp().
Or you could use dircmp(), but not all distros ship with it. My Slack box ships without cmpdir(), and I'm pretty sure your CentOS ships without as well.
Or you could use a view only command on the backup archive, such as: tar -tf; and compare it to your current directory listings...
Check the man pages for further customising of the functions above
Last edited by cin_; 01-18-2011 at 01:13 AM.
Reason: gramm'err
# man mysqldump
*WITHIN MAN PAGE /auto *TO SEARCH FOR INSTANCES OF 'auto'
#
... it seems to lack automatic backing, but you should check out what other options there are, perhaps one will do what you need...
Look into http://dev.mysql.com/doc/refman/5.0/en/binary-log.html
It seems one way MySQL can log changes. Perhaps you could use the log in conjunction with a script you write to run the backup in case of change and have the script patrol your log from cron...?
Or there could be an easier way...
How are you making the changes?
What changes are you making? To the database schema? Or files within?
Last edited by cin_; 01-18-2011 at 03:58 AM.
Reason: gramm'err
Here is how it works:
1) use AoE to "export" the block device of another box to your server.
2) make a RAID1 using the local drive and the "remote" drive
3) from now on, whatever is written on the local drive is replicated on the remote drive, so if disaster strikes you have a backup (which is physically outside your server). No need for complex scripts that replicate info every X seconds.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
MySQL certainly does have the capability of logging changes. See http://dev.mysql.com/doc/refman/5.1/...p-methods.html for a variety of options for backup. In particular, if you enable binary logging, you will be able to recover to any point in time.
You could also implement Zmanda Recovery Manager (ZRM) for MySQL -- http://www.zmanda.com/backup-mysql.html. It uses the native tools of MySQL and integrates them into a managed backup system for your database. You can use that to pull backups to another server on a regular schedule if you wish.
You should have a look at LVM snapshots. Using LVM snapshots you a guaranteed file system consistency. Haven't used it myself yet, but from what I know it may suit your needs.
I have one doubt, is copying /var/lib/mysql is a good alterntive to mysqldump?.
Because i use rsync to copy /var/lib/mysql for back up without dumping the database. I use rsync to do differential backup up so that it copies /var/lib/mysql to /var/tmp every one minute.
Does this idea worths or will it create any other problems.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
Quote:
Originally Posted by kenneho
You should have a look at LVM snapshots. Using LVM snapshots you a guaranteed file system consistency. Haven't used it myself yet, but from what I know it may suit your needs.
An LVM snapshot does not guarantee file system consistency. It reduces your exposure to change and the risk of inconsistencies.
If you have things running on your system that keep data and write it to disk, and you do a backup, then things can change on the disk while you are doing the backup. If you take a snapshot, and then backup the snapshot, then you don't have the ongoing exposure to change while the backup is being done. However, there could still be inconsistencies at the point in time when the snapshot was taken, because you have live applications running. This would be especially true of databases.
In order to be sure you have no inconsistencies, your system must be quiescent. That is, applications that might have data in memory, or things partially written out to different locations on disk, must be stopped, flushed, locked, whatever terminology and methods are appropriate for the application. Then you take the snapshot, start them up again, and proceed to backup the snapshot.
Going back to http://dev.mysql.com/doc/refman/5.1/...p-methods.html (referenced in my first post), the description of the use of snapshots for MySQL backup is at the end of that page. It's one way of doing it, but it isn't a complete solution. You need the binary logging to get incremental backups recoverable to any point in time. So, read the whole page and choose the method(s) most appropriate for your needs.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
Quote:
Originally Posted by dinakumar12
is copying /var/lib/mysql is a good alterntive to mysqldump?.
See my previous post and the link. Copying /var/lib/mysql risks inconsistencies when you recover, unless you go through the steps of flushing and locking tables and logs in MySQL. Then, to reduce the amount of time you have to leave tables locked, you can use some kind of file system snapshot. Following the recommendations from the MySQL site could avoid later problems when you need to recover.
Distribution: Ubuntu/Debian, CentOS, RHEL, FreeBSD, OS X
Posts: 75
Rep:
Generally speaking, you may get away on backing up your databases by copying /var/lib/mysql instead of using mysqldump. All of this depending on your environment.
However like choogendyk mentioned, you may look into database inconsistencies when it comes time to recover a database or a table.
One IMPORTANT thing to note is that recovering from /var/lib/mysql backups will only work if your database tables are not using the InnoDB storage engine. (Default starting MySQL 5.5)
By default MySQL keeps all the data of all InnoDB tables on two single data files. This means if your server has multiple databases that have InnoDB tables in them, recovering from the data file will certainly will affect ALL tables with that storage engine.
Ideally I would stick with mysqldump, disk storage is really cheap now days.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.