Have you ever live the nightmare of transfer to new server, it's really so hard to transfer a dozen of files and check every web application if it's still working after transfer the files and databases.

Specially if you're working for a web hosting company, It will be a daily task that will be a hard headache that will never end.

You gonna waste a long time doing that donkey work, and this task one of the most boring tasks ever, let's make it more fun and automated task, so you can have a drink (coffee or tea with mint flavor) until the hard work is done itself.

Do you feel the pain of corrupted files from compressing and decompressing after transfer. That always happen when the servers processors is not enough to do the task, or the files is too big.

You will not feel that pain again, you will only have to run a small shell script that will do all the task for you.

First you have to login the targeted server and create a public key to easily access the other server ssh without prompting the password every time

Second step, create a new file on the /root/ directory with the name trans.sh and put this script 

#!/bin/sh

<25>SERVER="[email protected]:/home"

helpFunction()
{
  echo ""
  echo "Usage: $0 account"
  exit 1 # Exit script after printing help
}

# Print helpFunction in case parameters are empty
if [ -z "$1" ]
then
  echo "Account name is empty";
  helpFunction
fi
rsync -rt ${SERVER}/$1 /home/

The file content on Github

Now you can run the script by typing the account name as parameter

sh trans.sh accountname

I hope you enjoy the simple script, now we should transfer the database, you can do that though any MySQL client like Navicat or Sqlyog and I'll write a new article of how to transfer databases between tow servers so easily using Shell script like that one or even through client application.

Stay creative, and I would see you next time. 

Category: hosting
Views: 7771

Muhammad El-Saeed

About author
Technical writer and software engineer, he's a part of the great Brightery team that have many project on the opensource community

{{comments.length}} Comments

{{comment.name}}

{{comment.name}} · {{comment.created}}

{{sc.name}}

{{sc.name}} · {{sc.created}}

Post your comment

64x64
Reply to {{parent.name}} close

Similar Stories


SEO

5 Free SEO tools to boost your search engine rankings 2019

5 free SEO tools to boost your search engine rankings 2019 SEO is the part that you should take good care of to make the the correct optimization to your website and drive more traffic easy and free from your targeted audience. This is the…

subject Read
Online Marketing

The best marketing tool - Brightery mega marketing tool.

Still doesn't know about brightery mega marketing tool? still having problems with considering what is the best marketing tool for 2019? This post going to help you decide. Brightery mega marketing When you make a little research for which is the best marketing tool on…

subject Read
Web Development

4 html responsive template free download from brightery

If you're looking for html responsive template free download then we're giving away the best 4 template html css free in the same same time.4 html responsive template free download  Royal HTML5 Free templateRoyal - Premium Free bootstrap templatesRoyal is multi-purposeful HTML, CSS, And JavaScript with many features…

subject Read