New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
$db = array ( 'db_account' , 'db_game' , 'db_misc'); foreach($db as $name){ if(!file_exists('backup/'.date('Y_m_d').'/')) { $do = mkdir('backup/'.date('Y_m_d')); exec($do); } if(!file_exists('backup/'.date('Y_m_d').'/'.$name.'/')) { $do = mkdir('backup/'.date('Y_m_d').'/'.$name); exec($do); } $tmpDir = '/tmp/'; $sqlFile = $tmpDir.$name.date('d_m_Y_H_i').'.sql'; $backupFile = $name.'_'.date('d_m_Y_H_i').'.tgz'; $create = "mysqldump -u ".$mysql_user." --password='".$mysql_pass."' --default-character-set=latin1 --hex-blob ".$dbName." > ".$sqlFile; $createZip = "tar cvzf $backupFile $sqlFile"; exec($create); exec($createZip); unlink($sqlFile); }
mysqldump is a good way then taring the same and then lets put in a folder where rsync will later do it job.
This code can be executed by a cronjob to make it easier.
Thank you!
This is exactly what I use for the game servers. You can also get a dropbox account + use dropboxuploader api php
https://github.com/jakajancar/DropboxUploader
to send to dropbox.
I have this in my backup script
As you can see, using mysqldump. Have no idea if it's the best option (probably not) but I'm not running any production databases anyway.
What happens when mysqldump runs while multiple tables are being updated that have relations between each other?
Lock tables, backup, unlock tables.
Dont forget foriegn key checks ( if the DB's tables have any )
This works well:
http://sourceforge.net/projects/automysqlbackup/
Try Percona's backup tools
I do master-slave replication and daily mysqldump on the slave.
As @gbshouse says - use Percona's backup tools otherwise you end up with inconsistencies.
+1 for Percona, if you have complex mySQL database.
+1 again for Percona.
Mysqldump is also reasonable for a secondary backup (i.e a partial backup for if the other backup fails).
Personally I have a Percona backup running daily, and a mysqldump partial backup of select tables run every 6 hours (in case of failure of backup, a backdated percona backup could be used + mysqldump for important tables).
On top of this full disk (e.g LVM) backups are also wise.
+1
Try this out, https://github.com/arjitc/DumpSQL
https://github.com/shyaminayesh/SQLBackup/blob/master/backup.sh
small bash for backup and upload to FTP if you are interesting.
MySQLDump piped to gzip then FTP elsewhere.
mysqldump is certainly acceptable. a better solution if you can is to setup a slave mysql server and run the dumps on slave.
^ This.
Assuming:
You could then use any of the above suggestions on the slave without much impact on "production" instances IMHO
You can also do filesystem snapshots, mount the snapshot and then dump that. That will give you a 100% point-in-time backup