Skip to content

Commit aa1627f

Browse files
committed
Updated CHANGELOG.md. Added new fields for local file owner file group and the local shared directory. Added Chown to all transferred files. Added theme file generation. Added a check for www in urls as well as non www. Unified more of the messages.
1 parent 81e06dd commit aa1627f

11 files changed

+120
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- New fields for local file owner and group, and local shared directory
10+
- Chown is now run for all transferred files.
11+
- Theme files now regenerated.
12+
13+
### Changed
14+
- Added check for www in domains when replacing urls
15+
- Updated some of the messaging to be more uniform.
16+
817

918
## [1.4.1] - 2020-09-08
1019
### Changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ $ db-sync.sh
3030
You can save a configuration file in the Magento directory to save answering some of the questions. An example is included in this repository [example.conf](./example.conf)
3131

3232
```bash
33-
remote_host=cotswoldcollections.com
34-
remote_domain=www.cotswoldcollections.com
33+
remote_host=domain.com
34+
remote_domain=www.domain.com
3535
remote_port=22
3636
remote_username=magento
3737
remote_magento_dir=/opt/magento/magento2
3838
remote_backup_dir=/opt/magento/backups
3939
remote_shared_deployment_dir=/opt/magento/deployment/shared/magento
40+
local_backup_dir=/opt/magento/backups
41+
local_shared_deployment_dir=/opt/magento/deployment/shared/magento
42+
local_file_user=magento
43+
local_file_group=magento
4044
```
4145

db-sync.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ echo -e "${txt_blue} Checking for local configuration file (${conf_file}). ${t
3232
echo -e ""
3333
if [[ -f "$conf_file" ]]; then
3434
. "$conf_file"
35+
echo -e "${txt_blue} Loaded from config. ${txt_end}"
3536
fi
3637

3738
set -e
3839

3940
# Set ${remote_host}
4041
source "${dbsyncutil}set_remote_host.sh"
42+
source "${dbsyncutil}set_local_vars.sh"
4143

4244
# Test Connection
4345
while true; do
@@ -88,11 +90,13 @@ echo -e ""
8890
n98-magerun setup:upgrade
8991
echo
9092
n98-magerun setup:di:compile
93+
echo
94+
n98-magerun setup:static-content:deploy -f -j8 en_GB en_US
9195
echo
9296
n98-magerun indexer:reindex
9397
echo
9498
n98-magerun cache:flush
9599

96100
echo -e "${bg_green}${txt_white}${txt_bold} ${txt_end}"
97-
echo -e "${bg_green}${txt_white}${txt_bold} Database migrated: ${txt_yellow}${domain} ${txt_end}"
101+
echo -e "${bg_green}${txt_white}${txt_bold} Database migrated: ${txt_yellow}${new_domain} ${txt_end}"
98102
echo -e "${bg_green}${txt_white}${txt_bold} ${txt_end}"

example.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ remote_username=magento
66
remote_magento_dir=/opt/magento/magento2
77
remote_backup_dir=/opt/magento/backups
88
remote_shared_deployment_dir=/opt/magento/deployment/shared/magento
9+
local_backup_dir=/opt/magento/backups
10+
local_shared_deployment_dir=/opt/magento/deployment/shared/magento
11+
local_file_user=magento
12+
local_file_group=magento

utils/local_backup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ if [ $_arg_local_backup == 'on' ]; then
66
echo -e "${txt_blue} Backing up local database(s).${txt_end}"
77
echo -e ""
88

9-
n98-magerun --ansi --root-dir="${PWD}" db:dump --compression="gzip" --force "../backups/$DATESTAMP-m2.sql.gz"
9+
n98-magerun --ansi --root-dir="${PWD}" db:dump --compression="gzip" --force "${local_backup_dir}/$DATESTAMP-m2.sql.gz"
1010

1111
if [ $_arg_wordpress == 'on' ]; then
12-
n98-magerun --ansi --root-dir="${PWD}" db:dump --compression="gzip" --connection="wordpress" --force "../backups/$DATESTAMP-wp.sql.gz"
12+
n98-magerun --ansi --root-dir="${PWD}" db:dump --compression="gzip" --connection="wordpress" --force "${local_backup_dir}/$DATESTAMP-wp.sql.gz"
1313
fi
1414
else
1515
# No local backup

utils/local_imagery_import.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ echo -e ""
77

88
# Set the default directories to transfer
99
source=("/pub/media/" "/wp/wp-content/uploads/")
10-
dest=("./pub/media/" "./wp/wp-content/uploads/")
10+
dest=("${local_shared_deployment_dir}/pub/media/" "${local_shared_deployment_dir}/wp/wp-content/uploads/")
1111

1212
for i in "${!source[@]}"; do
1313
rsync -rlDhP --exclude 'cache*' -e "ssh -p${remote_port}" "$remote_username@$remote_host:$remote_shared_deployment_dir${source[$i]}" "${dest[$i]}"
14+
chown -R $local_file_user:$local_file_group "${dest[$i]}"
1415
done

utils/local_import.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ echo -e ""
55
echo -e "${txt_blue} Importing into local database(s).${txt_end}"
66
echo -e ""
77

8-
mysql -h$DB_HOST -u$DB_USER -p$DB_PASS $DB_DBASE<../backups/latest-m2.sql
8+
mysql -h$DB_HOST -u$DB_USER -p$DB_PASS $DB_DBASE<$local_backup_dir/latest-m2.sql
99

1010
if [ $_arg_wordpress == 'on' ]; then
11-
mysql -h$DB_WP_HOST -u$DB_WP_USER -p$DB_WP_PASS $DB_WP_DBASE<../backups/latest-wp.sql
11+
mysql -h$DB_WP_HOST -u$DB_WP_USER -p$DB_WP_PASS $DB_WP_DBASE<$local_backup_dir/latest-wp.sql
1212
fi

utils/menu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dbsync_print_help() {
3939
Options:
4040
-b, --local-backup: perform a backup before importing remote (off by default)
4141
-f, --full: full database dump (off by default)
42-
-w, --wordpress: include wordpress content (off by default)"
42+
-w, --wordpress: include wordpress content (off by default)"
4343
-v, --version: Prints version
4444
-h, --help: Prints help
4545

utils/remote_retrieve.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ echo -e ""
88
remote_m2_db_file="$remote_backup_dir/latest-m2.sql.gz"
99
remote_wp_db_file="$remote_backup_dir/latest-wp.sql.gz"
1010

11-
mkdir -p ../backups
11+
while [[ -z ${local_backup_dir} ]]; do
12+
# prompt and set ${local_backup_dir}
13+
read -p $'\e[1mLocal host backup directory\e[0m: ' -r -e local_backup_dir
1214

13-
scp -C -P "${remote_port}" "${remote_username}@${remote_host}:$remote_m2_db_file" ../backups/latest-m2.sql.gz
14-
gunzip -f ../backups/latest-m2.sql.gz
15+
if [[ -z ${local_backup_dir} ]]; then
16+
echo -e "${txt_red}Local host backup directory is required${txt_end}"
17+
fi
18+
done
19+
20+
mkdir -p "${local_backup_dir}"
21+
22+
scp -C -P "${remote_port}" "${remote_username}@${remote_host}:${remote_m2_db_file}" "${local_backup_dir}/latest-m2.sql.gz"
23+
gunzip -f "${local_backup_dir}/latest-m2.sql.gz"
1524

1625
if [ $_arg_wordpress == 'on' ]; then
17-
scp -C -P "${remote_port}" "${remote_username}@${remote_host}:$remote_backup_dir/latest-wp.sql.gz" ../backups/latest-wp.sql.gz
18-
gunzip -f ../backups/latest-wp.sql.gz
26+
scp -C -P "${remote_port}" "${remote_username}@${remote_host}:${remote_backup_dir}/latest-wp.sql.gz" "${local_backup_dir}/latest-wp.sql.gz"
27+
gunzip -f "${local_backup_dir}/latest-wp.sql.gz"
1928
fi

utils/set_local_vars.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
# Set data
4+
echo -e ""
5+
echo -e "${txt_blue} Enter the local server info.${txt_end}"
6+
echo -e ""
7+
8+
# loop until validation
9+
while [[ -z ${local_backup_dir} ]]; do
10+
11+
# prompt and set ${local_backup_dir}
12+
read -p $'\e[1mLocal Backup Dir (full server path)\e[0m: ' -r -e local_backup_dir
13+
14+
if [[ -z ${local_backup_dir} ]]; then
15+
16+
echo -e "${txt_red}Local Backup Directory is required${txt_end}"
17+
18+
fi
19+
done
20+
21+
# loop until validation
22+
while [[ -z ${local_shared_deployment_dir} ]]; do
23+
24+
# prompt and set ${local_shared_deployment_dir}
25+
read -p $'\e[1mLocal Shared Dir (full server path)\e[0m: ' -r -e local_shared_deployment_dir
26+
27+
if [[ -z ${local_shared_deployment_dir} ]]; then
28+
29+
echo -e "${txt_red}Local Shared Directory is required${txt_end}"
30+
31+
fi
32+
done
33+
34+
while [[ -z ${local_file_user} ]]; do
35+
36+
# prompt and set ${local_file_user}
37+
read -p $'\e[1mFile Owner\e[0m: ' -r -e local_file_user
38+
39+
if [[ -z ${local_file_user} ]]; then
40+
41+
echo -e "${txt_red}File Owner is required${txt_end}"
42+
43+
fi
44+
done
45+
46+
while [[ -z ${local_file_group} ]]; do
47+
48+
# prompt and set ${local_file_group}
49+
read -p $'\e[1mFile Group\e[0m: ' -r -e local_file_group
50+
51+
if [[ -z ${local_file_group} ]]; then
52+
53+
echo -e "${txt_red}File Group is required${txt_end}"
54+
55+
fi
56+
done
57+
58+
echo -e "\n"
59+
echo -e " ${txt_green}Using the following for local host${txt_end}"
60+
echo -e " ${txt_green} Local Backup Directory: ${txt_yellow}${local_backup_dir}${txt_end}"
61+
echo -e " ${txt_green} Local Shared Deployment Directory: ${txt_yellow}${local_shared_deployment_dir}${txt_end}"
62+
echo -e " ${txt_green} Local File Owner: ${txt_yellow}${local_file_user}${txt_end}"
63+
echo -e " ${txt_green} Local File Group: ${txt_yellow}${local_file_group}${txt_end}"
64+
echo -e "\n"

0 commit comments

Comments
 (0)