Permalink
Browse files

Add db-scrub.sh and update-db.sh sample scripts.

  • Loading branch information...
1 parent f3a85a1 commit 850e6e3084b762b7fdcca6d7171bbaa7391887b2 @bjaspan bjaspan committed Nov 7, 2011
Showing with 44 additions and 0 deletions.
  1. +17 −0 samples/db-scrub.sh
  2. +16 −0 samples/db-scrub.sql
  3. +11 −0 samples/update-db.sh
View
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# db-copy Cloud hook: db-scrub
+#
+# Apply the SQL scrub script db-scrub.sql. To this use this hook
+# script, be sure to put db-scrub.sql in the same directory.
+#
+# Usage: db-copy site target-env db-name source-env
+
+site="$1"
+target_env="$2"
+db_name="$3"
+source_env="$4"
+
+scrub=/var/www/html/$site.$target_env/hooks/$target_env/db-scrub.sql
+echo "$site.$target_env: Scrubbing database $db_name"
+cat $scrub | drush @$site.$target_env ah-sql-cli --db=$db_name
View
@@ -0,0 +1,16 @@
+--
+-- Scrub important information from a Drupal database.
+--
+
+-- Remove all email addresses.
+UPDATE users SET mail=CONCAT('user', uid, '@example.com') WHERE uid != 0;
+
+-- Example: Disable a module by setting its system.status value to 0.
+-- UPDATE system SET status = 0 WHERE name = 'securepages';
+
+-- Example: Update or delete variables via the variable table.
+-- DELETE FROM variable WHERE name='secret_key';
+-- UPDATE variable SET url='http://test.gateway.com/' WHERE name='payment_gateway';
+
+-- IMPORTANT: If you change the variable table, clear the variables cache.
+-- DELETE FROM cache WHERE cid = 'variables';
View
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# Cloud Hook: update-db
+#
+# Run drush updatedb in the target environment. This script works as
+# any Cloud hook.
+
+site="$1"
+target_env="$2"
+
+drush @$site.$target_env updatedb --yes

0 comments on commit 850e6e3

Please sign in to comment.