From time to time I want to transfer a site from one host to another. I am not saying this is the best way, but it works for me. Some FTP/SCP clients allow you to drag and drop from window to window, but I haven't had success with that method. Assuming I have SSH and SCP, heres what I do:
- tar the public_html dir. ex: go to the public_html dir and type tar -cvf website.tar ./
- ssh to the new host and go to the target path
- scp root@<host>:<path to file, incl. filename> ./ ex: scp Denne email adresse bliver beskyttet mod spambots. Du skal have JavaScript aktiveret for at vise den. :/home/site/public_html/website.tar ./ (it will prompt for password)
- Untar. ex: tar -xvf website.tar
- Fix group and ownership. Ex: chown -R owner.group ./
- Next, you got to transfer databases.
- For this, I simply export from one side, then import at the other. Fix configs and connection strings if necessary.
For large databases:
- mysqldump databasename -u username -pPassword | gzip >databasename.sql.gz
- from new host, scp root@<host>:<path to file, incl. filename> ./ (will be prompted for password)
- gzip -d databasename.sql.gz
- login to mysql - mysql -u username -p
- use <databasename>;
- source <name of .sql file>;
- test.
Kategori: Programming