In an effort to ease some of my web development steps I plan on creating a script to automate everything. I run a drupal site and I need to set up a development environment quickly after I shut down the site for maintenance.
These are the steps that I need verified:
Steps to prepare the development environment
1. Drop all tables in my development Database (MySQL)
2. Remove all drupal files from development directory
Copying development site over to development
3. Copy main DB into dev DB
4. Copy drupal files to dev directory
Setting up the environment for testing
5. use sed (or a find and replace prog) to change $db_url = 'mysql://username: password@localhost/livedatabase'; to $db_url = 'mysql://username: password@localhost/devdatabase'; in drupal settings.php
6. Since the development site is accessible from the internet, I need to add some security to the new dev .htaccess file. I figured I could just add:
to a .txt file and use cat to dump it at the end of .htaccess.
So this is what I have so far, any help would be greatly appreciated.
Also I have Dreamhost so localhost will not work with connecting to MySQL databases I have to use something like 'mysql.sitename.com'
mysqldump -u[USERNAME] -p[PASSWORD] -h [HOSTNAME] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]
cd ~/devsite // safety measure for next line
rm -Rf ./*
$ mysqldump -u[USER] -p[PASSWORD] -h [HOSTNAME][DATABASE] | ssh email@example.com
cp ~/livesite/* ~/devsite/
I have no idea how to use sed need advice
cat ~/devsite/.htaccess << ~/htaccess-password.txt
Any advice would be greatly appreciated. Thanks!