Transfer Files or Backup from one Server to another Server
1. cPanel Remote Backup
This is the most easiest method used to transfer whole site backup from server to server. It makes use of the “Backups” feature in cPanel and needs to be enabled by your host.
To use this
1. Open the Backups manager in your cPanel and click “Generate/Download a Full Backup”
2. For Backup destination choose “Remote FTP Server (Passive Mode Transfer)”
3. Enter the FTP server, username and password
4. Enter the FTP server port (this is usually “21″)
5. Leave Remote Dir field empty
6. Hit “Generate Backup”
Your backup will now be passively generated and transfer from server to server using the net2ftp protocol. If you don’t see this option in your cPanel then you need to ask your host to enable it.
2. SSH
SSH is a network protocol that allows data to be exchanged over a secure channel between two computers. Now a days nearly every web host provides this on request. You will need the PuTTy client to connect to your server via SSH.
Once you are connected via PuTTy just follow the instructions:
1. Login to server 1 via SSH and open the folder which you want to backup e.g.
cd /home/somepath/to/yourwebsite/public_html
2. Make a compressed archive out of this folder using the command
tar -cvf sitepack.tar ./
3. Login to server 2 via SSH and use the command below to fetch the backup from server
wget yourdomain.com/sitepack.tar
4. Now uncompress the archive using the command
tar -xvf sitepack.tar
wget command for windows
You can copy the exe file from http://users.ugent.be/~bpuype/wget/#download
and paste the file into WINDOWS\system32 folder of your PC.
Now go to command prompt (Acessories > Command Prompt) and use wget command to download files as you do in linux
eg. wget http://joomlacode.org/gf/download/frsrelease/6828/22538/Joomla_1.0.15-Stable-Full_Package.zip
This will download Joomla 1.0.15 version on your machine
Change group and owners of files and folders on Linux server
chown command - change the owner of a file
You must be either the root user or the owner of the file in order to change the group ownership.
To change the group and owners of files and folders on the linux server use the below command
Set the file’s owner:
$ chown username filename
where username is the new owner of the file and filename is the file for which ownership need to be changed.
You can also set the file’s group at the same time. If the user name is followed by a colon and a group name, the file’s group will be changed as well.
$ chown username:usergroup filename
You can set the owner of a directory exactly the same way you set the owner of a file:
$ chown username dirname
In order to set the ownership of a directory and all the files in that directory (recursive), you’ll need the -R option:
$ chown -R username dirname
R stands for recursive because this command will recursively change the ownership of directories and their contents
Verbose mode
$ chown -v username somefile
changed ownership of ’somefile’ to username
Here, v stands for verbose. If you use the -v option, chown will list what it did (or didn’t do) to the file.
The verbose mode is especially useful if you change the ownership of several files at once. For example, this could happen when you do it recursively:
$ chown -Rv username somedir
changed ownership of ‘dirname/’ to username
changed ownership of ‘dirname/file1′ to username
changed ownership of ‘dirname/file2′ to username
chgrp - change the group ownership of a file
You must be either the root user or the owner of the file in order to change the group ownership.
chgrp works the same way as chown does, except it changes the file’s user group instead of the owner
$ chgrp usergroup filename
where usergroup is the newgroup to which the filename need to be assigned
after execution of the command, the file’s group has changed to usergroup, the file’s owner will still be the same.
The options of using chgrp are the same as using chown. So, for example, the -R and -v options will work with it just like they worked with chown:
$ chgrp -Rv usergroup dirname
changed group of ‘dirname/’ to usergroup
changed group of ‘dirname/file1′ to usergroup
changed group of ‘dirname/file2′ to usergroup
How to restore compressed mysql backup file
To restore compressed backup files you can do the following:If you need to restore a database that already exists, you’ll need to use mysqlimport command. The syntax for mysqlimport is as follows:
Enable Disable register global from .htaccess
At times, we need to set register_globals to on or to off and we cannot modify such directive of php from the php.ini for obvious motives.
Then we can plan register_globals to on or off through an entry in the file .htaccess in the following manner.
For on:
php_flag register_globals on
For off:
php_flag register_globals off
Mysql database migration using shell command
I had a problem migrating the large mysql databases from one server to another. When ever i tried to do that using some utility I got “Out of Memory” error.
After a bit of research work, I realized that big databases can be migrated using shell command easily
Below you can find instructions to move database from one hosting provider to another:
1. Make database backup
The following shell command will dump whole database into file “dump.sql”: shell> mysqldump -u [uname] -p [dbname] > [dump.sql] It will prompt you for database password. Type in the password ORshell> mysqldump –host=[hostname] –user=[username] –password=[passowrd] [database_name] > dump.sql
2. Back up the database
Pack that backup into archive (for example - tar.gz). The following shell command will pack file “dump.sql” into archive “dump.tar.gz”:
shell> tar -czvf dump.tar.gz ./dump.sql OR (for TAR that doesn’t support ‘z’ option):shell> tar -cvf - ./dump.sql | gzip -c > dump.tar.gz
3. Transfer the archived from one hosting provider to another using FTP or anything else.
4. Unpack that backup archive at new server.
shell> tar -zxvf ./dump.tar.gzOR (for TAR that doesn’t support ‘z’ option): shell> gunzip < ./dump.tar.gz | tar -xvf -
5. Restore database from dump file using native MySQL command-line tool - mysql
shell> mysql –host=[hostname] –user=[username] –password=[password] [database_name] < dump.sql To view how to restore mysql from compressed mysql file Pleasit visit http://blog.technointellects.com/how-to-restore-compressed-mysql-backup-file/compress directory under Linux using shell prompt
How can I compress a whole directory under Linux / UNIX using a shell prompt?
It is useful to backup files, email all files. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:
1. Create the archive
2. Compress the archive
You need to use tar command as follows (syntax of tar command):
tar -zcvf archive-name.tar.gz directory-name
Where,
- -z: Compress archive using gzip program
- -c: Create archive
- -v: Verbose i.e display progress while creating archive
- -f: Archive File name
For example, you have directory called /home/demo/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf demo-11-july-2008.tar.gz /home/demo/prog
Above command will create an archive file called demo-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory):
$ tar -zxvf demo-11-july-2008.tar.gz
Where,
- -x: Extract files
If you wish to extract files in particular directory, for example in /tmp then you need to use following command:
$ tar -zxvf demo-11-july-2008.tar.gz -C /tmp
$ cd /tmp
$ ls

