Monday, March 22, 2010

Mysqldump

this how the usual CLI for mysqldump
mysqldump -u username -p dbname > backupname.sql

restore back from mysql

mysql -u username -p dbname '<' yousqldumpfile.sql

Recently, I was facing problem to restore a UTF8-Enabled database which stores a lot of Arabic text in the db itself.

I have to re-dump back the db by appending the --default-character-set=charset_name option in the dump command :

mysqldump -uroot -p --default-character-set=utf8 --databases yourdbname > yourdumpfile.sql

To restore, again you have to append the same option :

mysql -uroot -p --default-character-set=utf8 '<' youdumpsql.sql ** i need to add '<' because i will become hidden in this blog,if you want tu use the sqldump please to remove ' at '<' on restore CLI.

Thanks

Tuesday, March 16, 2010

Backup filesystem using dumpfs (FreeBSD)

finally i got to backup filesystem using dumpfs

- i got script from this web http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/
- touch a new file name "dumpfs.sh" and put at /usr/local/sbin/
- paste the script inside dumpfs.sh
- set at /etc/crontab

to restore from backup dumps
- restore rf 20100305_0


reference :
- http://my.galagzee.com/2009/07/17/freebsd-dump-filesystem-shell-script/

Tuesday, March 9, 2010

Vmware format ubuntu add hdd

Let's get going!
Removing and creating a partition
Having decided your drive's name (let's call it sda) we must now remove the default partition that the manafacturer put there:
sudo fdisk /dev/sda
This will start fdisk. We want to remove the partion(s), there should only be one.
Press d (for delete).
It might ask you for the partition number, press 1 and enter. If there are more then delete them too.

Now to make a new partition.
Press n (for new), then p (for primary), then 1 and then simply press enter for the next two questions.
This will make a new partition that uses the entire disk. If you want more complex partitioning then read the fdisk manual (man fdisk) or use parted or some other app.
Here's what we did with n, the values will differ from yours:

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (197-621, default 197):
Using default value 197
Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M


Now to write the new partion and exit, press w and enter.
You should be ready to make a filesystem now.

Making a filesystem : "Formatting"
You need to put a system in-place, on the disk, such that it can handle files. This is called (unsurprisingly) a filesystem.
The one we are going to use is called "ext3". On Gnu/Linux we are spoiled for choice and there are loads of filesystems you can use, go do some research if you want to.
So, let's make the filesystem:sudo mkfs.ext3 /dev/sda1
* Note the 1 at the end, because we are making the filesystem in that partition (thanks Mike)

Now it will go off and do strange stuff, simply wait for it to finish.

Using the new file system
Well, at this point you should be able to right-click on the icon (on your Desktop) and choose "mount" (I assume that's the verb it will present to you). After that you should be able to open a window and use the drive*
* all this assumes it's an external USB drive.
If you cannot then you will need to mount it yourself, try:
sudo mkdir /media/sda1
sudo mount /dev/sda1 /media/sda1
Note: We are actually mounting the first partition on the drive, hence the 1 at the end: sda1
And the mounted directory can be anywhere you like, but its common location is /media.

Monday, March 8, 2010

Change location HDD from original VM to another VM

If you have 1 server seperate 2 HDD example 1 for OS & another for data. Let talk about when the OS have a problem than how gonna you take out the HDD data to another VM machine. So this tutorial i made for me and for you as a knowledge tp know.

server A - original server have 2 HDD
server B - server

scenario

- when OS in server A crash or corrupted, don't panic! here the step. your data is save because you have a separated HDD on your VM.
- firstly create your new VM, install OS (for me i using Freebsd) after finish please add another HDD when the installation is completed. so now you have 2 HDD (the size on additional HDD depend on your server & need (in my case i create same capacity with the original server capacity for data))
- log in into server B and format the HDD using sysinstall (fdisk & label) the HDD. (remember to add at /etc/fstab for your new HDD)
- after finish format, open VM client browse the datastore your server A located.
- copy the second HDD.vmdk ( by default your HDD will namely nameserver_1.vmdk) copy this file and browse the folder server B & paste inside the folder server B.
- after finish copy you need to rename your the vmdk file that you copy from server B. To this try to ssh inside the vmware machine, by default your vm not allow the ssh protocol you need to open it.
- ssh your VM, go to /vmfs/volumes/datastore1 , go to path your server directory
- backup the nameserverB_1.vmdk to nameserverB_1ORI.vmdk
- rename the vmdk that you copy before nameserverA_1.vmdk to nameserverB_1.vmdk
- turn on your VM.

DONE

Tuesday, March 2, 2010

htpasswd tips

to add another user on htpasswd file

htpasswd -s alimdevpass username

Monday, March 1, 2010

FreeBSD (add extra HDD on VMWare Environment)

FreeBSD add another HDD on VMWARE and format it

- shutdown your server.
- open your vmware & choose the server you want to add
- edit & add HDD
- Turn on your server.
- become as root type sysinstall
- choose configure & FDISK
- choose a additional HDD that you add before. (BEWARE!!! Do not edit the existing HDD on your server,this may cause your server corrupted!)
- choose entire disk if you want to use all disk & W button (write)
- please choose NONE "do not tpuch master boot record"
- after finish push q button
- go back to main menu & choose Label (this is use to label your HDD)
- select C to create the FS (depend on your need) exp : /test01
- and select W to write the changes
- Select Q and edit at FSTAB (ee /etc/fstab)
- add this line to you fstab line
exp : /dev/da1s1 /test01 ufs rw 2 2
- save and reboot your server.