Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm very new to Ubuntu and my first task is to copy one website with a MySQL database to another server. Both servers are virtual machines and in the same environment. I have both the IP addresses and login credentials.

I can sign in remotely from my Windows computer to both machines of course (old server has Ubuntu 10.10 , new server has Ubuntu 12.04).

Now I need to know if i can either copy directly from one Ubuntu server to another or first to my computer and then to the other Ubuntu server.

Or are there maybe many solutions?

share|improve this question

closed as off-topic by Iain, MDMarra, Dave M, Christopher Perrin, mdpc Aug 9 '13 at 17:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – MDMarra, Christopher Perrin, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

In posting my answer, I find I need a bit more information on your setup. Firstly there's multiple dialects of SQL - I've covered mysql (and I believe its derivatives) and postgres. This would be very different for other databases. Likewise configuration of webservers varies wildly, especially taking into account scripting languages. I've posted a generic answer but if you could add this in, I can improve my answer further. – Journeyman Geek Aug 9 '13 at 11:15
This is non trivial and requires way more information than you have provided. YOu should take a look at… it and it's associated scripts may help you. – Iain Aug 9 '13 at 11:17
i use MySQL Database , thanks – RayofCommand Aug 9 '13 at 11:59
i don't know why you guys downvote this.... – RayofCommand Aug 9 '13 at 13:19
up vote 1 down vote accepted

You can use rsync for this,

we are assuming that you have ssh access to both server's, is for old one, and the uname is the same on both servers and the file tree to copy is /var/somedir login to the new server,

rsync -av* /var/somedir/ 

It will login to and prompt for authentication, then build a file list and copy the content to the target on the current server.

I hope you understand this...
Thank you

share|improve this answer
rsync probably is a better choice for file transfers than sftp or scp as I suggested in my answer - especially if you're moving large files. – Journeyman Geek Aug 9 '13 at 12:52

Firstly, one dosen't simply walk into mordor, I mean copy databases. You need to do this right. You'll want to make sure there's no ongoing writes, then make sure everything is copied in a ACID manner. You could shut down the database, move it, then get hit with the realisation things went horribly wrong cause they're different versions...

Luckily mysql comes with a tool to do this called mysqldump - and there's a question on SO on using it with lots of syntax examples - It should be something like mysql -u<user> -p < db_backup.dump. I would also recommend checking the versions since you may need to run an upgrade script between versions. Move the DUMP file, don't copy the database. Run the dump, run the upgrade script, test. As you can tell, Mysql has good resources on it, so read up and make sure you know what you're doing.

If you're using postgres, there's also pg_dump (which has an oh so elegant syntax). And its file level backup documentation is true anywhere - since shutting down a server is the surest way to not have writes while you're backing up, mucking up consistancy.

To move the dump file while there's quite a few methods SFTP is probably the ideal combination of speed and security. You can transfer files computer to computer with pscp or download them to your windows system, then reupload them with cyberduck. Since you already have SSH, this should be the simplest way to do this.

Web server configuration, and files (IE, the effective contents of /etc/ and /var/www) should be alright to copy, since they arn't constantly being changed.

share|improve this answer
Called mysqldump. Remember to extract all, including stored procedures. – fsoppelsa Aug 9 '13 at 11:03
Thanks, corrected that. I guess I remembered the name incorrectly, and had googled for sqldump op pull up the documentation – Journeyman Geek Aug 9 '13 at 11:05
thank you for this explicit answer Sir Journeyman Geek – RayofCommand Aug 9 '13 at 11:42

You can use scp or rsync for sending files/directories between your Ubuntu servers directly.


scp -r /local_dir/path user@otherhost:/remote_dir/path

Databases can be migrated by using the backup/dump and restore functionality that's typically provided by your DB server software (MySQL, Postegres, etc.). The exact process depends on your database server.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.