Wednesday, February 18, 2009

backing up mysql in rough terrains

I recently got a hold of a new domain, which is hosted on a virtualization, managed with plesk.

and so it turns out, the MySql DB of the CMS had to be backed up (practice!).
now, plesk offers only a conclusive plesk server backup, which covers the db, but a lot more, and you cannot extract the db from it.
phpMyAdmin on the other hand, could not deal with the size of the db, and export simply failed giving me blanks any way i tried to go about it.

the DB files were also not accessible via FTP, so my last resort was SSH & SCP.
the trick is that them files were sitting on a restrictive area that only super user is allowed to access, and SCP doesn't offer su services.
so i did as following:

1. login via SSH with my user.
2. su root (provided pwd)
3. mkdir /home/myUserDir/temp
3. cp /var/mysql/dbName/* /home/myUserDir/temp/.
5. chmod 777 * (making them readable to everyone)

then i went to my windows command line and run:
5. pscp myuser@myserver.com:/home/myUserDir/temp/* "c:\temp\."
6. rm /home/myUserDir/temp/*
7. rmdir /home/myUserDir/temp

and voila - they are here...

come to think of it, i could've added in my .bash_profile the su command and maybe pscp could've then copy directly from the /var director...maybe next time?!

content is king, and I'm quite content :-)

UPDATE:
It comes to show you that late night work is not always preferable.

duh! how about using mysqldump instead of copying the db files?
this would've saved me the need for su, and file copying to my home directory.

the new procedure:
1. ssh to machine, with normal user.
2. mysqldump > /home/myUserDir/temp
3. pscp...

far easier...

No comments:

Post a Comment