Portal Home > Knowledgebase > Articles Database > How to easiest do backup and transfer of mysql files ?


How to easiest do backup and transfer of mysql files ?




Posted by Klentelaris, 06-29-2008, 04:02 PM
I have following problem-i have over 20 sites on server and each site has own database.Is there a way to speed up backup and transfer or other server? Method which i use right now it's following:first i archive entire directory using command tar -pczf name.tar.gz public_html,and then repeat with each directory.But i think i could simply archive all requied directories,but that will took toomuch time,so if i drop connection during archiving it wont be archived at all then.So i think best solution will be to create some kind of batch command which can load in background,so that means command wont stop if client lost connection. So let's say i have 2 sites and two directories located and different places. One is at home/site1 and other at home/site2 So i think i would need to put command into batch file tar -pczf site.tar.gz. /home/site1 and tar -pczf site2.tar.gz /home/site2 Will that work? Also second part,mysql databases,i founded if i login into phpmyadmin as root i can see all databases.I managed to export all databases,but question will import again to phpmyadmin work.I think phpmyadmin create command for each database "if there is no db sitename_mysqlbase,create it",but howmuch i know phpmyadmin have limit with importing size of mysql database.Could that be done with import/export mysql command ?

Posted by midav, 06-29-2008, 05:32 PM
If you have Cpanel control panel on your current server the best way to trabsfered your accouns is to create FULL backup of your account via Cpanel's web interface or shell: /scripts/pkgacct

Posted by david510, 06-29-2008, 05:33 PM
If you have root access to the server, you can compress the files using tar. If you fear the connection will be lost, you can create a screen and run the process there. Process will run inside the screen even if the connection is lost. To create a new screen screen -S newscreen If the connection is lost and after you re-login to the server you can see the screen using the command screen -list You can get into the running screen using the command screen -R screen_name You can use mysqldump utility to backup the databases and scp the dump files to the remote server and restore it from the shell itself.

Posted by osphere, 06-29-2008, 08:39 PM
PHPMyAdmin has some nice backup features

Posted by activelobby4u, 06-30-2008, 12:58 AM
simple process would be to write a script which implements the following 1. mysqldump db_name > some_directory_in_home_directory_of_the_domain 2. Archive the home directories in a single tar.gz using tar -zcvvf home.tar.gz /home 3. Run the script in cron. Probably you can add a variable to denote the date , if you wish to keep the backups for some days This is an alternate method. There are 1000 ways to do this

Posted by Klentelaris, 06-30-2008, 08:29 AM
Actualy best tar command will be following:where i can write what i want to archive(which directory)and where i can archive it so i can put it into batch file and that batch file i will add to cron. So in shortly,i would need proper command for mysql output which can overwrite previous mysql file and do extract without asking for password and tar command which can archive directories with all files and subdirectories inside and point to to desired location.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read