Quick and Dirty on the Command Line

Here's what I did: I logged into hosted server via ssh and used the command line to first dump the MySql database to a convenient place (usually ./site/all/backup/db) and then tar up and compress the whole file structure. Follow these steps:

1. The information you need is the name of the database together with the database user and password:

[email protected] [~]# cd public_html/sites/all/backup/db [email protected] [~/public_html/sites/all/backup/db]# grep \ mysql ../../../default/settings.php

$db_url = 'mysql://username:[email protected]/databasename'; [email protected] [~/public_html/sites/all/backup/db]# mysqldump -u\ username -p databasename > awebfact.sql

Enter password:

[email protected] [~/public_html/sites/all/backup/db]# ls ./ ../ awebfact.sql

[email protected] [~/public_html/sites/all/backup/db]#

As an alternative with very large databases, gzip the result directly, like this:

[email protected] [~/public_html/sites/all/backup/db]# mysqldump -u \

username -p databasename | gzip > awebfact.gz

2. Tar the whole Drupal installation, including this database dump:

[email protected] [~/public_html/sites/all/backup/db]# cd ../../../..

[email protected] [~/public_html]# tar cvzf ../awebfactory.tgz .

3. You now download the tarball (awebfactory.tgz) and untar it in your test site document root:

[email protected]: ~/Work/AWebFactory/awebfactory.com.ar/public_html$ tar xvzf

../awebfactory.tgz

4. Now create the local database, create the user with a password with access to only that database, insert the database dump into the newly created test database, and fire up the local mirror! Here are the final steps (you can find them in the file INSTALL.mysql.txt, in the Drupal document root):

[email protected]: ~/Work/AWebFactory/awebfactory.com.ar/public_html $ mysqladmin\

-u adminuser -p create databasename Enter password:

[email protected]: ~/Work/AWebFactory/awebfactory.com.ar/public_html $ mysql -u\

adminuser -p Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 508

Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE

-> TEMPORARY TABLES, LOCK TABLES -> ON databasename.*

-> TO 'username'@'localhost' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.03 sec)

mysql> quit

Bye [email protected]: ~/Work/AWebFactory/awebfactory.com.ar/public_html\ $ mysql -u username -p databasename < sites/all/backup/db/awebfact.sql Enter password:

[email protected]: ~/Work/AWebFactory/awebfactory.com.ar/public_html$ All set, you have the mirror running now on the test site!

Common Caveats

Cat got your .htaccess file? Layout, CSS weird? Clean URLs no longer working, resulting in ''404 Not Found'' errors? You used a method to copy the files that omitted Linux ''hidden files'' (the ones starting with a dot: like .htaccess). Solution: copy in the .htaccess file from a fresh Drupal install.

What's that? .htaccess file is there, but things just not right, maybe your browser is offering to download php pages instead of serving them? The problem might be that the .htaccess file is specifically adjusted to your production site environment. Copy it to the test site using the same method you used to copy the other Drupal files.

0 0

Post a comment