Wednesday, April 21, 2010

How To Rsync at Freebsd Using ssh.

Before rsync,your have to make sure your BSD box already insttaled rsync. If you don't have it please to do so and please to install both of your server.

You can install rsync using ports (Please to csup your ports 1st to get the new packages)

#cd /usr/ports/net/rsync/
#make config
#make && make install
#rehash.

Start to rsync.

i am only rsync forder usr/src.
#rsync -av -e "ssh -l admin" root@servername:/usr/src/ /usr/src/

After finish do not reboot, please re-compile.
** I recommended to csup the stable_supfile 1st before your compile your kernel.

#cd /usr/src
#make cleanworld && make cleandir
#make buildworld
#make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
#make installworld
#make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
#reboot

Then start to rsync other folder.
Your can exclude any folder that you think not necessary.
I am rsync some folder such as boot or usr/src.

#rsync -av --exclude=/boot --exclude=/usr/src -e "ssh -l admin" root@servername:/ /

password will be prompted. Then enter password. wait until finish the rsync.

After finish

change ip address,hostname and vhost.

To change hostname.
#ee /etc/hosts

To change ip address
#ee /etc/rc.conf

to change vhost ** If you use it.
# ee /usr/local/etc/apache22/extra/httpd-vhosts.conf

then reboot your server

Rsync on linux box

Consider you already have 2 Linux server then open terminal or ssh at the new Linux server.

type command below

#rsync -av --exclude=/boot-e ssh username@oldserverhost:/(source) /(destination)

or standard rsync

#rsync -av -e ssh username@oldserverhost:/home/old_home/ /home/new_home/


password will be prom then enter password.
i exclude boot file because it need difficult configuration. You also can exclude the folder you want to rsync too such as /root /home /lib or anything else.

After finish the transferring data, your have to reconfigure, the Ip address,hostname or any necessary file need such as apache, mysql or others that you use.

*Ip tables or firewall at linux sometime need to stop to running the application.

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.