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 


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

  echo ""
  echo "Usage: $0 account"
  exit 1 # Exit script after printing help

# Print helpFunction in case parameters are empty
if [ -z "$1" ]
  echo "Account name is empty";
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: 6724

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.created}}


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

Post your comment

Reply to {{parent.name}} close

Similar Stories


Social media agencies Dubai: Guide to knowing more

 Social media agencies Dubai: Guide to knowing moreSocial media has become an important part of good marketing strategy in this digital age.  As social media continues to grow, businesses must choose to remain relevant and reach their target  audience effectively. This is where our social media agencies…

subject Read

Tips to hire the best agency and to find your best branding agency in the world

 Stop searching for " the best agency near me "If you're looking for the best agency with the best employment agency members, If you're looking forward to work with the best agency in the world or the best branding agency in the world.Tips to hire…

subject Read
Search Engine Optimization

How does Googlebot making the google index website process?

How does Googlebot making the google index website process, And how google index site using google crawler and bots? learn the basics of making google easily index your website. and make it as quick as possible.How Long Googlebot ( Google crawler ) for Making Google…

subject Read