Example: Copy the Film website
Using info from http://drupal.org/upgrade/copying-your-live-site-via-command-line
=-=-=
1. Using the terminal, change directory to film website directory.
% ls -s
total 5584
8 Desktop DB 0 Webserver/
8 Desktop DF 0 film-2012.ucsc.edu/
5568 FilmDigitalMediaSocialDocumentaryatUCSantaCruz-2012-10-27T01-08-32.mysql
8 Desktop DB 0 Webserver/
8 Desktop DF 0 film-2012.ucsc.edu/
5568 FilmDigitalMediaSocialDocumentaryatUCSantaCruz-2012-10-27T01-08-32.mysql
0 film.ucsc.edu/
2. Is there enough space? Ask df
% df
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/disk8s3 2147221288 12413944 2134807344 1% /Volumes/Web HD1
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/disk8s3 2147221288 12413944 2134807344 1% /Volumes/Web HD1
3. Copy the Existing Site
% cp -Rp film.ucsc.edu film-2012.ucsc.edu
or for copying between hosts:
% tar -cf film2012.tar film.ucsc.edu
then copy to the new host via Finder copy, ftp or rcp, and extract:
% tar -xf film2012.tar
4. Create the Empty Database
% mysqladmin -u (admin user here) -p create film2012
Enter password:
% mysqladmin -u (admin user here) -p create film2012
Enter password:
5. Fire up Command Line MySQL
% mysql -u (admin user here) -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 340238
Server version: 5.x.xx-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
% mysql -u (admin user here) -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 340238
Server version: 5.x.xx-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
6. Grant Privileges on the New Empty Database
mysql> GRANT ALL PRIVILEGES ON film2012.* TO fdm@localhost IDENTIFIED BY '(admin password of existing db here)';
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql> quit;
Bye
[arts:/Volumes/Web HD1] administrator% ls
total 5584
8 Desktop DB 0 film-2012.ucsc.edu/
8 Desktop DF 0 film-2012.ucsc.edu-old/
5568 FilmDigitalMediaSocialDocumentaryatUCSantaCruz-2012-10-27T01-08-32.mysql 0 film.ucsc.edu/
0 Webserver/
mysql> GRANT ALL PRIVILEGES ON film2012.* TO fdm@localhost IDENTIFIED BY '(admin password of existing db here)';
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql> quit;
Bye
[arts:/Volumes/Web HD1] administrator% ls
total 5584
8 Desktop DB 0 film-2012.ucsc.edu/
8 Desktop DF 0 film-2012.ucsc.edu-old/
5568 FilmDigitalMediaSocialDocumentaryatUCSantaCruz-2012-10-27T01-08-32.mysql 0 film.ucsc.edu/
0 Webserver/
Use mysqldump to Copy Database Contents from Old to New Database
[arts:/Volumes/Web HD1] administrator% mysqldump help
[snip...]
[arts:/Volumes/Web HD1] administrator% mysqldump --user=(admin user here) --password=(mysql admin password here) existingdatabase | mysql --user=(admin user here) --password=(mysql admin password here) copyofexistingdatabase
Done!