|
|
|
Table of contents:
|
|
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
|
|
# To take a database dump of any feature branch environment and download it to your MAC below are the steps.
|
|
|
|
1. cd to webroot
|
|
|
|
```bash
|
|
|
|
cd /var/www/docker_platform/web
|
|
|
|
```
|
|
|
|
in case of drupal 7
|
|
|
|
```bash
|
|
|
|
cd /var/www/docker_platform/docroot
|
|
|
|
```
|
|
|
|
1. Execute Drush sql dump and compress it.
|
|
|
|
```bash
|
|
|
|
drush sql-dump --gzip > /var/www/doc_platform/web/dbdump.sql.gz
|
|
|
|
```
|
|
|
|
In case of Drupal 7
|
|
|
|
```bash
|
|
|
|
drush sql-dump --gzip > /var/www/doc_platform/docroot/dbdump.sql.gz
|
|
|
|
```
|
|
|
|
1. Now go to url and access the file like below (example: https://qa-commerce8.d.commerce.gov/dbdump.sql.gz)
|
|
|
|
|
|
|
|
1. Next, remove the file with
|
|
|
|
```bash
|
|
|
|
rm -f /var/www/doc_platform/web/dbdump.sql.gz
|
|
|
|
```
|
|
|
|
in case of Drupal 7
|
|
|
|
```bash
|
|
|
|
rm -f /var/www/doc_platform/default/dbdump.sql.gz
|
|
|
|
```
|
|
|
|
|
|
|
|
# Take a database dump of any Production site
|
|
|
|
|
|
|
|
1. [Log into portainer](https://portainer.d.commerce.gov/).
|
|
|
|
1. Open and connect to the console of ANY D8 site container for D8 prod dumps, Authenticator container for Auth prod dumps, or a D7 site container for D7 prod site dumps (e.g. branch environment containers from any developer).
|
|
|
|
1. Navigate to `/root` path:
|
|
|
|
```bash
|
|
|
|
cd ~
|
|
|
|
```
|
|
|
|
1. Execute script `pull-prod-db.sh` with an argument to it as below.
|
|
|
|
* `commerce` or `authenticator` for D8 prod dumps **OR**
|
|
|
|
* `socmed`,`acetool`,`citrb`,`ocio`,`ogc`,`medweek`,`mbda`,`es`,`cc` for D7 prod dumps.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
```bash
|
|
|
|
./pull-prod-db.sh socmed
|
|
|
|
```
|
|
|
|
1. That will download the sql file to `/var/www/docker_platform/docroot/sites/default/` or `/var/www/docker_platform/web/sites/default` folder based on drupal version.
|
|
|
|
|
|
|
|
## Replace container database with production instance
|
|
|
|
1. Make sure you are in
|
|
|
|
* D7: `/var/www/docker_platform/docroot/sites/default/` or
|
|
|
|
* D8: `/var/www/docker_platform/web/sites/default`
|
|
|
|
1. Gather the container database connection details in `settings.php` (with information in [ALL CAPS IN BRACKETS] to be of note)
|
|
|
|
```php
|
|
|
|
$databases['default']['default'] = array (
|
|
|
|
'database' => '[DATABASENAME]',
|
|
|
|
'username' => '[USERNAME]',
|
|
|
|
'password' => '[PASSWORD]',
|
|
|
|
'prefix' => '',
|
|
|
|
'host' => '[HOST IP ADDRESS]',
|
|
|
|
'port' => '3306',
|
|
|
|
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
|
|
|
|
'driver' => 'mysql',
|
|
|
|
);
|
|
|
|
```
|
|
|
|
1. Get the name of the database dump (should match the project name:
|
|
|
|
```bash
|
|
|
|
ls | grep .sql
|
|
|
|
```
|
|
|
|
|
|
|
|
Example output: `commerce.sql`
|
|
|
|
1. Formulate mysql command to put prod db dump into existing database:
|
|
|
|
```bash
|
|
|
|
mysql -h [HOST IP ADDRESS] -p -u [USERNAME] [DATABASENAME] < [database dump.sql]
|
|
|
|
```
|
|
|
|
|
|
|
|
Example of what it might look like:
|
|
|
|
```bash
|
|
|
|
mysql -h 123.456.789.101 -p -u database_user database_name < commerce.sql
|
|
|
|
```
|
|
|
|
1. Enter that command, and then enter the corresponding password
|
|
|
|
1. Wait... It'll take some time.
|
|
|
|
|
|
|
|
## Download it to your local machine (mac, pc, etc)
|
|
|
|
1. Move the file to the `/var/www/docker_platform/docroot/` or `/var/www/docker_platform/web/` folder based on drupal version.
|
|
|
|
```bash
|
|
|
|
mv dbdump.sql (or dbdump.sql.gz if already zipped) ../../
|
|
|
|
```
|
|
|
|
1. Zip file if not already zipped with
|
|
|
|
|
|
|
|
```bash
|
|
|
|
gzip dbdump.sql
|
|
|
|
```
|
|
|
|
1. Change ownership of file to ```www-data:www-data``` with
|
|
|
|
|
|
|
|
```bash
|
|
|
|
chown www-data:www-data mbda.sql.gz
|
|
|
|
```
|
|
|
|
1. Now go to url and access the file like below:
|
|
|
|
Example:
|
|
|
|
https://qa-commerce8.d.commerce.gov/dbdump.sql.gz
|
|
|
|
1. Next, remove the file with
|
|
|
|
|
|
|
|
```bash
|
|
|
|
rm -f /var/www/doc_platform/web/sites/default/dbdump.sql.gz
|
|
|
|
```
|
|
|
|
in case of Drupal 7
|
|
|
|
```bash
|
|
|
|
rm -f /var/www/doc_platform/sites/default/dbdump.sql.gz
|
|
|
|
``` |
|
|
|
\ No newline at end of file |