
rabbit+list at rabbit
Jan 14, 2009, 6:28 AM
Post #8 of 12
(1413 views)
Permalink
|
|
Re: [Slightly OffTopic] Backing up dbmail ( error 2013 )
[In reply to]
|
|
Niblett, David A wrote: > Dan, > > I know you are using mysql, but if ever you were to move to > Postgres, I'm using the Point in Time Recovery (PITR) setup. > This has been great for making backups when your database > is large (mine is around 52G). > > Restore could take you longer, but my opinion is, if I'm to > the point that I have to restore it's better to have the > data and take longer to restore, than to not or cause > performance hits every day to backup the data. > > Basically the PITR saves the transaction logs of the database. > So I just copy the database every Sunday early morning, then > just archive out the transaction logs to another drive as they > fill up. > > If I should have to recover, I just copy back in the last Sunday > copy of the DB and tell Postgres to playback the transaction log > files. The really nice thing is if I think it was a DB corruption > problem, I can say restore everything to 5m before the crash. > > Just another thought for you. > I do absolutely the same with my 60GB mysql database: in mysql.cnf: ================= log_bin = /space/system/mysql/binlog/mysql-bin * log_bin_index = /space/system/mysql/binlog/mysql-bin.index * server_id = 1 expire_logs_days = 20 max_binlog_size = 500M * You can use the defaults, I am just copying my complete example here in my backup script: ======================= /usr/bin/mysql --defaults-extra-file=/etc/mysql/debian.cnf \ --execute "FLUSH TABLES WITH READ LOCK, LOGS; SYSTEM /sbin/lvcreate --snapshot --size $S_LV_SIZE --chunksize 512K --name $S_LV $VG/$LV &>/dev/null ; UNLOCK TABLES;" where the variables are just fill-ins as per the lvcreate manpage. WHat this does is: 1) flush all pending writes and lock the database as read-only 2) force a binlog rotation so you know exactly where the snapshot was taken 3) make a LV snapshot (takes care of all sync()s at fs level) 4) unlock everything (the lock persists while the snapshto is created, which lasts about half a second) Then I go ahead and slowly backup/compress/whatever I want the database files from the snapshot volume When shit hits the fan: =========================== 1) Stop the database 2) Unpack the mysql data directory saved from the latest snapshot (since the snapshot was made within a read-lock, the database is guaranteed to be consistent) 3) Start the database, but make sure no connections are accepted (as the data is healthy but old) 4) gather all binlog files since the snapshot was taken (correlate the backup script run time with the snapshot timestamos) 5) replay them using the wonderful mysqlbinlog utility 6) go back to sleep _______________________________________________ DBmail mailing list DBmail [at] dbmail https://mailman.fastxs.nl/mailman/listinfo/dbmail
|