![]() | |
#1
| |||
| |||
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~| Malcolm Hoar "The more I practice, the luckier I get". | malch (AT) malch (DOT) com Gary Player. | http://www.malch.com/ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ |
#2
| ||||||
| ||||||
|
|
I am relatively new to MySQL. My database uses Innodb and |
|
I have binary logging enabled. |
|
Here is my proposed backup strategy: # Raw backup cd /var/lib/mysql service mysql stop tar -cvf /root/mysqlbinbackup/20110519.tar . service mysql start gzip /root/mysqlbinbackup/20110519.tar chmod 600 /root/mysqlbinbackup/20110519.tar.gz |
|
# mysqldump mysqldump -u root -p --single-transaction --flush-logs --master-data=2 --delete-master-logs --opt Zebra > /root/mysqldumpbackup/20110519.sql gzip /root/mysqldumpbackup/20110519.sql chmod 600 /root/mysqldumpbackup/20110519.sql.gz |
|
Of course, I already have seperate backups of my.cnf as well as my database schema. |
|
Does this make sense? Any classic newbie errors or ommissions that are likely to result in tears? |
#3
| ||||||||
| ||||||||
|
|
Supposing that /var/lib/mysql is your datadir and that InnoDB is configured to put it's table spaces and redo logs into it ... then this will give you a complete physical backup of your MySQL instance. |
|
Of course, I already have seperate backups of my.cnf as well as my database schema. Not sure what you mean by "database schema". But the logical schema of all your databases is already in the above. The `Zebra` schema twice already. |
|
Does this make sense? Any classic newbie errors or ommissions that are likely to result in tears? I have no idea what your goal is. But if you can live with shutting down MySQL for the backup, then the first part is enough already. OK, you might want to PURGE old binlogs too. |
|
Mysqldump has the advantage that the MySQL server can stay up during backup. And with using --single-transaction, it would not even lock any tables. Physical backup OTOH is a) faster to backup and b) much faster to restore. |
|
Enabling the binlog will allow you to do point-in-time recovery. Are you planning to use this? |
|
Have you RTFM? |
|
http://dev.mysql.com/doc/refman/5.1/...-recovery.html |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~| Malcolm Hoar "The more I practice, the luckier I get". | malch (AT) malch (DOT) com Gary Player. | http://www.malch.com/ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ |
#4
| ||||
| ||||
|
|
In article <4p7ga8-aje.ln1 (AT) xl (DOT) homelinux.org>, axel.schwenke (AT) gmx (DOT) de wrote: I have no idea what your goal is. But if you can live with shutting down MySQL for the backup, then the first part is enough already. OK, you might want to PURGE old binlogs too. Well, at this point, I want to cover all of my bases. You can never have too many backups and all that... ;-) |
|
Yes, I think shutting down for the backups is acceptable at this point. However, it could become a problem down the road as the data volumes (times) increase and so do user demands. |
|
Mysqldump has the advantage that the MySQL server can stay up during backup. And with using --single-transaction, it would not even lock any tables. Physical backup OTOH is a) faster to backup and b) much faster to restore. Yes, and I think the Mysqldump backup would also be highly portable to another server if the primary met with some catastrophe like a fire, natural disaster etc., right? |
|
Enabling the binlog will allow you to do point-in-time recovery. Are you planning to use this? Yes, again I want to keep all of my options open at this point. Frankly I'm hoping to avoid any point-in-time recoveries but just in case. I have considered replicating this database too. I think that's overkill at this point but it may become a factor and a binary log would be the first pre-requistite for replication, right? |
#5
| |||||
| |||||
|
|
malch (AT) malch (DOT) com (Malcolm Hoar) wrote: In article<4p7ga8-aje.ln1 (AT) xl (DOT) homelinux.org>, axel.schwenke (AT) gmx (DOT) de wrote: I have no idea what your goal is. But if you can live with shutting down MySQL for the backup, then the first part is enough already. OK, you might want to PURGE old binlogs too. Well, at this point, I want to cover all of my bases. You can never have too many backups and all that... ;-) I wouldn't second that. Of course you need one complete backup. But it doesn't make much sense to have multiple backups of the same thing from the same time. |
|
What you need much more, is to test your restore process: does it work at all? Is it fast enough? Is the restored data ok? Yes, I think shutting down for the backups is acceptable at this point. However, it could become a problem down the road as the data volumes (times) increase and so do user demands. It's quite unusual to have a daily maintenance window that allows to shutdown the database. But if you are that lucky, then doing a physical backup that way is probably easiest and fastest. |
|
There is one pitfall here: if you have physical data corruption, then this might go unnoticed for a long time (longer than you keep old backups and binlogs). This could be overcome by either testing backups regularly (restore to a spare machine and run CHECK TABLE on all tables). Or do a SQL dump occasionally. |
|
Mysqldump has the advantage that the MySQL server can stay up during backup. And with using --single-transaction, it would not even lock any tables. Physical backup OTOH is a) faster to backup and b) much faster to restore. Yes, and I think the Mysqldump backup would also be highly portable to another server if the primary met with some catastrophe like a fire, natural disaster etc., right? The physical backup is just as portable - if we talk about restoring data into MySQL. The SQL dump is more portable in the sense that you can use it to load data into a different DBMS. Or that you can use any kind of software to extract data from it, split it, modify it in a certain way etc. |
|
The physical backup is less flexible you cannot even restore a single (InnoDB) table from it. It's all-or-nothing. Enabling the binlog will allow you to do point-in-time recovery. Are you planning to use this? Yes, again I want to keep all of my options open at this point. Frankly I'm hoping to avoid any point-in-time recoveries but just in case. I have considered replicating this database too. I think that's overkill at this point but it may become a factor and a binary log would be the first pre-requistite for replication, right? Sure. But if you want to be ready for PITR (aka incremental backup/ recovery), then there are some additional requirements for the full backups: - you must backup all databases - the backup must be a snapshot (all objects in the backup must be from the same point in time) - your backup must include the information of the binlog number and file position at that point in time The physical backup as you do it, conforms to this (the binlog position is implicit because MySLQ starts a new binlog when it is restarted). The partial SQL dump however does not. XL |
#6
| |||
| |||
|
|
He's right, Axel - in the real world (which you have never experienced), you can't have too many backups. But you can always have too few. |
|
The physical backup is just as portable - if we talk about restoring data into MySQL. And if you're restoring to the exact same version of MySQL on the exact same operating system and the exact same options... But all bets are off if any of that changes. |
#7
| |||
| |||
|
|
FTR: I answer mostly to correct the stucklish nonense Jerry Stuckle <jstucklex (AT) attglobal (DOT) net> wrote: He's right, Axel - in the real world (which you have never experienced), you can't have too many backups. But you can always have too few. You see, some people prefer to do things right. And then it's enough to do it only once. OTOH I'm not astonished to see that you are among those who don't trust their own craft and rather do things twice. |
|
The physical backup is just as portable - if we talk about restoring data into MySQL. And if you're restoring to the exact same version of MySQL on the exact same operating system and the exact same options... But all bets are off if any of that changes. Wrong. You can restore to any platform. And to any MySQL version from the same or the next major release. |
#8
| ||||||
| ||||||
|
|
I wouldn't second that. Of course you need one complete backup. But it doesn't make much sense to have multiple backups of the same thing from the same time. |
|
What you need much more, is to test your restore process: does it work at all? Is it fast enough? Is the restored data ok? |
|
There is one pitfall here: if you have physical data corruption, then this might go unnoticed for a long time (longer than you keep old backups and binlogs). This could be overcome by either testing backups regularly (restore to a spare machine and run CHECK TABLE on all tables). Or do a SQL dump occasionally. |
|
The physical backup is just as portable - if we talk about restoring data into MySQL. |
|
Sure. But if you want to be ready for PITR (aka incremental backup/ recovery), then there are some additional requirements for the full backups: |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~| Malcolm Hoar "The more I practice, the luckier I get". | malch (AT) malch (DOT) com Gary Player. | http://www.malch.com/ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ |
#9
| |||
| |||
|
|
FTR: I answer mostly to correct the stucklish nonense Jerry Stuckle<jstucklex (AT) attglobal (DOT) net> wrote: He's right, Axel - in the real world (which you have never experienced), you can't have too many backups. But you can always have too few. You see, some people prefer to do things right. And then it's enough to do it only once. OTOH I'm not astonished to see that you are among those who don't trust their own craft and rather do things twice. |
|
The physical backup is just as portable - if we talk about restoring data into MySQL. And if you're restoring to the exact same version of MySQL on the exact same operating system and the exact same options... But all bets are off if any of that changes. Wrong. You can restore to any platform. And to any MySQL version from the same or the next major release. XL |
#10
| |||
| |||
|
|
In article <rqhha8-tg4.ln1 (AT) xl (DOT) homelinux.org>, axel.schwenke (AT) gmx (DOT) de wrote: I wouldn't second that. Of course you need one complete backup. But it doesn't make much sense to have multiple backups of the same thing from the same time. Sure it does. One on-site and one off-site, for starters. Mandatory as far as I'm concerned. |
|
The physical backup is just as portable - if we talk about restoring data into MySQL. Not across operating systems. |
|
I'm not a huge fan of incremental backups. Sometimes they're a necessary evil but I plan to skip that unless/until the data volumes force the issue. |
![]() |
| Thread Tools | |
| Display Modes | |
| |